fix: update command parsers to require explicit service arguments
Some checks failed
Nix Format Check / check-format (push) Waiting to run
Python Lint Check / check-python (push) Waiting to run
Ansible Lint Check / check-ansible (push) Failing after 13s

This commit is contained in:
Menno van Leeuwen 2025-03-12 21:26:19 +01:00
parent f53297b17f
commit d3a00bef3e
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE

View File

@ -265,23 +265,15 @@ def main():
# Start command
start_parser = subparsers.add_parser("start", help="Start a Docker service")
start_parser_group = start_parser.add_mutually_exclusive_group(required=True)
start_parser_group.add_argument(
"--all", action="store_true", help="Start all services"
)
start_parser_group.add_argument("service", nargs="?", help="Service to start")
start_group = start_parser.add_mutually_exclusive_group(required=True)
start_group.add_argument("--all", action="store_true", help="Start all services")
start_group.add_argument("--service", dest="service", help="Service to start")
# Stop command
stop_parser = subparsers.add_parser("stop", help="Stop a Docker service")
stop_parser_group = stop_parser.add_mutually_exclusive_group(required=False)
stop_parser_group.add_argument(
"--all", action="store_true", help="Stop all running services"
)
stop_parser_group.add_argument("service", help="Service to stop")
# Make one of the arguments required
stop_parser.set_defaults(service=None)
stop_parser_group.required = True
stop_group = stop_parser.add_mutually_exclusive_group(required=True)
stop_group.add_argument("--all", action="store_true", help="Stop all running services")
stop_group.add_argument("--service", dest="service", help="Service to stop")
# Restart command
restart_parser = subparsers.add_parser("restart", help="Restart a Docker service")
@ -292,11 +284,11 @@ def main():
"update",
help="Update a Docker service (pull new images and recreate if needed)",
)
update_parser_group = update_parser.add_mutually_exclusive_group(required=True)
update_parser_group.add_argument(
update_group = update_parser.add_mutually_exclusive_group(required=True)
update_group.add_argument(
"--all", action="store_true", help="Update all running services"
)
update_parser_group.add_argument("service", nargs="?", help="Service to update")
update_group.add_argument("--service", dest="service", help="Service to update")
# PS command
ps_parser = subparsers.add_parser("ps", help="Show Docker service status")