print help if there are no sub-commands given
This commit is contained in:
@@ -209,6 +209,8 @@ def setup_maintenance_parser(subparsers):
|
||||
maintenance_parser = subparsers.add_parser(
|
||||
"maintenance", help="Maintenance operations"
|
||||
)
|
||||
# Store reference to parser for help display
|
||||
setup_maintenance_parser._parser = maintenance_parser
|
||||
maintenance_subparsers = maintenance_parser.add_subparsers(
|
||||
dest="maintenance_action", help="Maintenance actions"
|
||||
)
|
||||
@@ -263,7 +265,15 @@ def handle_maintenance_command(args, client):
|
||||
"""Handle maintenance command execution"""
|
||||
maintenance_commands = MaintenanceCommands(client)
|
||||
|
||||
if args.maintenance_action == "list":
|
||||
if not args.maintenance_action:
|
||||
if hasattr(setup_maintenance_parser, "_parser"):
|
||||
setup_maintenance_parser._parser.print_help()
|
||||
else:
|
||||
print(
|
||||
"Error: No maintenance action specified. Use --help for usage information."
|
||||
)
|
||||
return False
|
||||
elif args.maintenance_action == "list":
|
||||
maintenance_commands.list_maintenances()
|
||||
elif args.maintenance_action == "add":
|
||||
title = (
|
||||
|
@@ -218,6 +218,8 @@ class MonitorCommands:
|
||||
def setup_monitor_parser(subparsers):
|
||||
"""Setup monitor command parser"""
|
||||
monitor_parser = subparsers.add_parser("monitor", help="Monitor operations")
|
||||
# Store reference to parser for help display
|
||||
setup_monitor_parser._parser = monitor_parser
|
||||
monitor_subparsers = monitor_parser.add_subparsers(
|
||||
dest="monitor_action", help="Monitor actions"
|
||||
)
|
||||
@@ -277,7 +279,15 @@ def handle_monitor_command(args, client):
|
||||
"""Handle monitor command execution"""
|
||||
monitor_commands = MonitorCommands(client)
|
||||
|
||||
if args.monitor_action == "list":
|
||||
if not args.monitor_action:
|
||||
if hasattr(setup_monitor_parser, "_parser"):
|
||||
setup_monitor_parser._parser.print_help()
|
||||
else:
|
||||
print(
|
||||
"Error: No monitor action specified. Use --help for usage information."
|
||||
)
|
||||
return False
|
||||
elif args.monitor_action == "list":
|
||||
monitor_commands.list_monitors(
|
||||
monitor_patterns=args.monitor, group_patterns=args.group
|
||||
)
|
||||
|
Reference in New Issue
Block a user