diff --git a/main.py b/main.py index 0c324aa..2509526 100644 --- a/main.py +++ b/main.py @@ -262,10 +262,21 @@ class Switch: post_reboot = requests.post(url_reboot, data=json.dumps(data), headers=self.headers) +limit = False if "--limit" in sys.argv: - list_index = sys.argv.index("--limit") + 1 - if len(sys.argv) >= list_index: + limit = True + limit_list_index = sys.argv.index("--limit") + 1 + if len(sys.argv) <= limit_list_index: raise RuntimeError("--limit must be followeb by a comma separated list of switch") + limit_switchs = set( + filter( + bool, + map( + lambda x: x.strip(), + sys.argv[limit_list_index].split(',') + ) + ) + ) #if "--force" in sys.argv: # sw = Switch()