From e0ed4b19cdce03f1e750ee646351b06f76303955 Mon Sep 17 00:00:00 2001 From: Tulsi Swami Date: Sun, 27 Jun 2021 17:12:02 +0530 Subject: [PATCH] code refactoring --- chaos-client.py | 21 +++++++++++---------- chaos_python/client.py | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/chaos-client.py b/chaos-client.py index f0731d7..8b23d30 100644 --- a/chaos-client.py +++ b/chaos-client.py @@ -1,15 +1,5 @@ -import requests import argparse from chaos_python.client import chaosAPI as chaosapi - -parser = argparse.ArgumentParser(description='Python client to communicate with Chaos API', add_help=True) -required = parser.add_argument_group('Required arguments') -required.add_argument('--domain', metavar='example.com', help='Domain to find subdomains for', required=True) -required.add_argument('--key', metavar='xxxxxxxxxxx', help='Chaos key for API', required=True) -chaos_opt = parser.add_argument_group('Optional arguments') -_ = chaos_opt.add_argument('--count', action='store_true', help='Show statistics for the specified domain') -_ = chaos_opt.add_argument('--json', action='store_true', help='Show statistics for the specified domain') -args = parser.parse_args() def main(): if args.count: @@ -22,4 +12,15 @@ def main(): print(f"{subdomain}") if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Python client to communicate with Chaos API', add_help=True) + + required = parser.add_argument_group('Required arguments') + required.add_argument('--domain', metavar='example.com', help='Domain to find subdomains for', required=True) + required.add_argument('--key', metavar='xxxxxxxxxxx', help='Chaos key for API', required=True) + + chaos_opt = parser.add_argument_group('Optional arguments') + chaos_opt.add_argument('--count', action='store_true', help='Show statistics for the specified domain') + chaos_opt.add_argument('--json', action='store_true', help='Show statistics for the specified domain') + + args = parser.parse_args() main() \ No newline at end of file diff --git a/chaos_python/client.py b/chaos_python/client.py index 5ffa366..35553d7 100644 --- a/chaos_python/client.py +++ b/chaos_python/client.py @@ -16,4 +16,4 @@ def chaosAPI(domain, key, opt): elif opt == 'json': return response else: - return "Please define an options" \ No newline at end of file + return "Please define an option" \ No newline at end of file