Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 225b1f7

Browse files
Make Rookify execute in dry-run mode by default
Signed-off-by: Boekhorst <[email protected]> Co-authored-by: Tobias Wolf <[email protected]>
1 parent ad6f0da commit 225b1f7

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

src/rookify/__main__.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,33 @@ def parse_args(args: list[str]) -> argparse.Namespace:
1515
# Putting args-parser in seperate function to make this testable
1616
arg_parser = ArgumentParser("Rookify")
1717

18-
# --dry-run option
19-
arg_parser.add_argument("--dry-run", action="store_true", dest="dry_run_mode")
18+
arg_parser.add_argument(
19+
"-d",
20+
"--dry-run",
21+
action="store_true",
22+
dest="dry_run_mode",
23+
help="Preflight data analysis and migration validation.",
24+
)
2025

2126
arg_parser.add_argument(
27+
"-m",
28+
"--migrate",
29+
action="store_true",
30+
dest="execution_mode",
31+
help="Run the migration.",
32+
)
33+
34+
arg_parser.add_argument(
35+
"-s",
2236
"--show-states",
2337
action="store_true",
2438
dest="show_states",
2539
help="Show states of the modules.",
2640
)
2741

42+
if len(args) < 1:
43+
args = ["--dry-run"]
44+
2845
return arg_parser.parse_args(args)
2946

3047

@@ -39,7 +56,7 @@ def main() -> None:
3956

4057
# Configure logging
4158
try:
42-
if args.show_states is True:
59+
if args.show_states:
4360
configure_logging(
4461
{"level": "ERROR", "format": {"renderer": "console", "time": "iso"}}
4562
)
@@ -51,16 +68,19 @@ def main() -> None:
5168
# Get Logger
5269
log = get_logger()
5370

54-
log.info("Executing Rookify ...")
55-
5671
machine = Machine(config["general"].get("machine_pickle_file"))
5772

5873
load_modules(machine, config)
5974

60-
if args.show_states is True:
75+
if args.show_states:
76+
log.debug("Showing Rookify state ...")
6177
ModuleHandler.show_states(machine, config)
62-
else:
78+
elif args.dry_run_mode:
79+
log.info("Running Rookify in dry-run mode ...")
6380
machine.execute(dry_run_mode=args.dry_run_mode)
81+
else:
82+
log.info("Executing Rookify ...")
83+
machine.execute()
6484

6585

6686
if __name__ == "__main__":

tests/test_main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717

1818
# fmt: off
1919
test_cases: List[TestCase] = [
20-
(["--dry-run"], argparse.Namespace(dry_run_mode=True, show_states=False)),
21-
(["--show-states"], argparse.Namespace(dry_run_mode=False, show_states=True)),
22-
(["--dry-run", "--show-states"], argparse.Namespace(dry_run_mode=True, show_states=True)),
23-
([], argparse.Namespace(dry_run_mode=False, show_states=False)),
20+
(["--migrate"], argparse.Namespace(dry_run_mode=False, show_states=False, execution_mode=True)),
21+
(["--migrate", "--dry-run"], argparse.Namespace(dry_run_mode=True, show_states=False, execution_mode=True)),
22+
(["--dry-run"], argparse.Namespace(dry_run_mode=True, show_states=False, execution_mode=False)),
23+
(["--show-states"], argparse.Namespace(dry_run_mode=False, show_states=True, execution_mode=False)),
24+
(["--dry-run", "--show-states"], argparse.Namespace(dry_run_mode=True, show_states=True, execution_mode=False)),
25+
([], argparse.Namespace(dry_run_mode=True, show_states=False, execution_mode=False)),
2426
]
2527
# fmt: on
2628

0 commit comments

Comments
 (0)