From b3b043f796b7b61be1d1d60ca84491b596d8ff4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krystian=20Du=C5=BCy=C5=84ski?= Date: Fri, 28 Apr 2023 21:00:33 +0200 Subject: [PATCH] moved generating file before checking reset files --- mikrotik_configurator/__main__.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mikrotik_configurator/__main__.py b/mikrotik_configurator/__main__.py index 57a6b25..719366c 100644 --- a/mikrotik_configurator/__main__.py +++ b/mikrotik_configurator/__main__.py @@ -44,18 +44,6 @@ def main(): print("mixed up order") exit(1) - if args.reset and orders[0] != 0: - print("reset must start with 0_0") - exit(1) - - if not args.reset and orders[0] == 0: - print("not reset can't start with 0_0") - exit(1) - - if not dry_run and args.reset: - if not query_yes_no("Are you sure you want to reset configuration?", "no"): - exit(1) - def gen(x): s = f'\n/log info message="starting {x}..."\n' s += generator.render_file(x, cfg.get("include_dirs", []), cfg.get("variables", {})) @@ -75,6 +63,18 @@ def main(): print(script) return + if args.reset and orders[0] != 0: + print("reset must start with 0_0") + exit(1) + + if not args.reset and orders[0] == 0: + print("not reset can't start with 0_0") + exit(1) + + if not dry_run and args.reset: + if not query_yes_no("Are you sure you want to reset configuration?", "no"): + exit(1) + for index, line in enumerate(script.splitlines(), start=1): print('{:4d}: {}'.format(index, line.rstrip()))