Restore behavior where 'kumacli monitor' shows the subcommands
This commit is contained in:
@@ -182,6 +182,7 @@ def setup_maintenance_parser(subparsers):
|
||||
maintenance_parser = subparsers.add_parser(
|
||||
"maintenance", help="Maintenance operations"
|
||||
)
|
||||
setup_maintenance_parser.parser = maintenance_parser
|
||||
maintenance_subparsers = maintenance_parser.add_subparsers(
|
||||
dest="maintenance_action", help="Maintenance actions"
|
||||
)
|
||||
@@ -239,9 +240,7 @@ def handle_maintenance_command(args, client):
|
||||
maintenance_commands = MaintenanceCommands(client)
|
||||
|
||||
if not args.maintenance_action:
|
||||
print(
|
||||
"Error: No maintenance action specified. Use --help for usage information."
|
||||
)
|
||||
setup_maintenance_parser.parser.print_help()
|
||||
return False
|
||||
if args.maintenance_action == "list":
|
||||
maintenance_commands.list_maintenances()
|
||||
|
@@ -162,6 +162,7 @@ class MonitorCommands:
|
||||
def setup_monitor_parser(subparsers):
|
||||
"""Setup monitor command parser"""
|
||||
monitor_parser = subparsers.add_parser("monitor", help="Monitor operations")
|
||||
setup_monitor_parser.parser = monitor_parser
|
||||
monitor_subparsers = monitor_parser.add_subparsers(
|
||||
dest="monitor_action", help="Monitor actions"
|
||||
)
|
||||
@@ -222,7 +223,7 @@ def handle_monitor_command(args, client):
|
||||
monitor_commands = MonitorCommands(client)
|
||||
|
||||
if not args.monitor_action:
|
||||
print("Error: No monitor action specified. Use --help for usage information.")
|
||||
setup_monitor_parser.parser.print_help()
|
||||
return False
|
||||
if args.monitor_action == "list":
|
||||
monitor_commands.list_monitors(
|
||||
|
@@ -50,13 +50,16 @@ class TestCLIIntegration:
|
||||
mock_args = Mock()
|
||||
mock_args.monitor_action = None
|
||||
|
||||
# Setup parser reference to simulate having called setup_monitor_parser
|
||||
mock_parser = Mock()
|
||||
setup_monitor_parser.parser = mock_parser
|
||||
|
||||
# Execute
|
||||
result = handle_monitor_command(mock_args, mock_client)
|
||||
|
||||
# Verify
|
||||
assert result is False
|
||||
captured = capsys.readouterr()
|
||||
assert "Error: No monitor action specified" in captured.out
|
||||
mock_parser.print_help.assert_called_once()
|
||||
|
||||
def test_maintenance_help_message(self, mock_client, capsys):
|
||||
"""Test maintenance command shows help when no action specified"""
|
||||
@@ -64,13 +67,16 @@ class TestCLIIntegration:
|
||||
mock_args = Mock()
|
||||
mock_args.maintenance_action = None
|
||||
|
||||
# Setup parser reference to simulate having called setup_maintenance_parser
|
||||
mock_parser = Mock()
|
||||
setup_maintenance_parser.parser = mock_parser
|
||||
|
||||
# Execute
|
||||
result = handle_maintenance_command(mock_args, mock_client)
|
||||
|
||||
# Verify
|
||||
assert result is False
|
||||
captured = capsys.readouterr()
|
||||
assert "Error: No maintenance action specified" in captured.out
|
||||
mock_parser.print_help.assert_called_once()
|
||||
|
||||
def test_monitor_command_with_full_args(self, mock_client):
|
||||
"""Test monitor command with complete argument structure"""
|
||||
|
Reference in New Issue
Block a user