Skip to content

Commit

Permalink
fix: use dryrun as default and add migrate as executing command
Browse files Browse the repository at this point in the history
Signed-off-by: Boekhorst <[email protected]>
  • Loading branch information
boekhorstb1 committed Sep 30, 2024
1 parent 96f1ebd commit c69c906
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
24 changes: 14 additions & 10 deletions src/rookify/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ def parse_args(args: list[str]) -> argparse.Namespace:
)

arg_parser.add_argument(
"run",
nargs="?",
default=False,
"-m",
"--migrate",
action="store_true",
dest="execution_mode",
help="Run the migration.",
)

# Show help if no arguments are provided
if not args:
arg_parser.print_help()
sys.exit(1)

return arg_parser.parse_args(args)
print("No arguments provided.")
return arg_parser.parse_args(["--dry-run"])
else:
return arg_parser.parse_args(args)


def main() -> None:
Expand All @@ -63,16 +64,19 @@ def main() -> None:
# Get Logger
log = get_logger()

log.info("Executing Rookify ...")

machine = Machine(config["general"].get("machine_pickle_file"))

load_modules(machine, config)

if args.show_states is True:
log.info("Showing Rookify state ...")
ModuleHandler.show_states(machine, config)
if args.run:
elif args.dry_run_mode is True:
log.info("Running Rookify in dry-run-mode ...")
machine.execute(dry_run_mode=args.dry_run_mode)
elif args.execution_mode is True:
log.info("Executing Rookify ...")
machine.execute()


if __name__ == "__main__":
Expand Down
10 changes: 6 additions & 4 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@

# fmt: off
test_cases: List[TestCase] = [
(["--dry-run"], argparse.Namespace(dry_run_mode=True, show_states=False)),
(["--show-states"], argparse.Namespace(dry_run_mode=False, show_states=True)),
(["--dry-run", "--show-states"], argparse.Namespace(dry_run_mode=True, show_states=True)),
([], argparse.Namespace(dry_run_mode=False, show_states=False)),
(["--migrate"], argparse.Namespace(dry_run_mode=False, show_states=False, execution_mode=True)),
(["--migrate", "--dry-run"], argparse.Namespace(dry_run_mode=True, show_states=False, execution_mode=True)),
(["--dry-run"], argparse.Namespace(dry_run_mode=True, show_states=False, execution_mode=False)),
(["--show-states"], argparse.Namespace(dry_run_mode=False, show_states=True, execution_mode=False)),
(["--dry-run", "--show-states"], argparse.Namespace(dry_run_mode=True, show_states=True, execution_mode=False)),
([], argparse.Namespace(dry_run_mode=True, show_states=False, execution_mode=False)),
]
# fmt: on

Expand Down

0 comments on commit c69c906

Please sign in to comment.