diff --git a/cmd/picoclaw/internal/gateway/command.go b/cmd/picoclaw/internal/gateway/command.go index a3ffafcfc..6c171f4dc 100644 --- a/cmd/picoclaw/internal/gateway/command.go +++ b/cmd/picoclaw/internal/gateway/command.go @@ -1,6 +1,8 @@ package gateway import ( + "fmt" + "github.com/sipeed/picoclaw/cmd/picoclaw/internal/status" "github.com/spf13/cobra" ) @@ -15,9 +17,13 @@ func NewGatewayCommand() *cobra.Command { Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { // If "status" is provided as an argument, delegate to status command - if len(args) > 0 && args[0] == "status" { - status.StatusCmd() - return nil + if len(args) > 0 { + if args[0] == "status" { + status.StatusCmd() + return nil + } + // Reject unknown arguments + return fmt.Errorf("unknown argument: %s (did you mean 'picoclaw status'?)", args[0]) } // Otherwise, start the gateway return gatewayCmd(debug) diff --git a/cmd/picoclaw/internal/gateway/command_test.go b/cmd/picoclaw/internal/gateway/command_test.go index 411bb4d64..bbd4954b2 100644 --- a/cmd/picoclaw/internal/gateway/command_test.go +++ b/cmd/picoclaw/internal/gateway/command_test.go @@ -30,3 +30,22 @@ func TestNewGatewayCommand(t *testing.T) { assert.True(t, cmd.HasFlags()) assert.NotNil(t, cmd.Flags().Lookup("debug")) } + +func TestGatewayCommandStatusArgument(t *testing.T) { + cmd := NewGatewayCommand() + + // Test that "status" argument is accepted and routes correctly + err := cmd.RunE(cmd, []string{"status"}) + // StatusCmd() doesn't return an error, so this should succeed + assert.NoError(t, err) +} + +func TestGatewayCommandUnknownArgument(t *testing.T) { + cmd := NewGatewayCommand() + + // Test that unknown arguments are rejected + err := cmd.RunE(cmd, []string{"foo"}) + require.Error(t, err) + assert.Contains(t, err.Error(), "unknown argument: foo") + assert.Contains(t, err.Error(), "did you mean 'picoclaw status'?") +}