diff --git a/cmd/workspace/list.go b/cmd/workspace/list.go index 5f5aa1badb..e93f33a49a 100644 --- a/cmd/workspace/list.go +++ b/cmd/workspace/list.go @@ -23,7 +23,7 @@ import ( type ListCmd struct { *flags.GlobalFlags - SkipPro bool + SkipPlatform bool } // NewListCmd creates a new destroy command. @@ -42,8 +42,16 @@ func NewListCmd(globalFlags *flags.GlobalFlags) *cobra.Command { }, } - cliflags.Add(listCmd, - cliflags.Bool(&cmd.SkipPro, names.SkipPro, false, "Don't list platform workspaces"), + cliflags.Add( + listCmd, + cliflags.Bool( + &cmd.SkipPlatform, + names.SkipPlatform, + false, + "Don't list platform workspaces", + ), + cliflags.Bool(&cmd.SkipPlatform, names.SkipProAlias, false, "Don't list platform workspaces"). + Hidden(), ) return listCmd } @@ -55,7 +63,7 @@ func (cmd *ListCmd) Run(ctx context.Context) error { return err } - workspaces, err := workspace.List(ctx, devsyConfig, cmd.SkipPro, cmd.Owner) + workspaces, err := workspace.List(ctx, devsyConfig, cmd.SkipPlatform, cmd.Owner) if err != nil { return err } diff --git a/cmd/workspace/list_test.go b/cmd/workspace/list_test.go new file mode 100644 index 0000000000..a3a9e5eaf4 --- /dev/null +++ b/cmd/workspace/list_test.go @@ -0,0 +1,48 @@ +package workspace + +import ( + "testing" + + "github.com/devsy-org/devsy/cmd/flags" + "github.com/devsy-org/devsy/pkg/flags/names" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestListCmdSkipPlatformFlag(t *testing.T) { + tests := []struct { + name string + args []string + want bool + }{ + {name: "defaults to false", args: nil, want: false}, + {name: "skip-platform sets value", args: []string{"--" + names.SkipPlatform}, want: true}, + { + name: "skip-pro alias sets same value", + args: []string{"--" + names.SkipProAlias}, + want: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + cmd := NewListCmd(&flags.GlobalFlags{}) + require.NoError(t, cmd.ParseFlags(tt.args)) + + got, err := cmd.Flags().GetBool(names.SkipPlatform) + require.NoError(t, err) + assert.Equal(t, tt.want, got) + }) + } +} + +func TestListCmdSkipProAliasIsHidden(t *testing.T) { + cmd := NewListCmd(&flags.GlobalFlags{}) + + alias := cmd.Flags().Lookup(names.SkipProAlias) + require.NotNil(t, alias) + assert.True(t, alias.Hidden) + + visible := cmd.Flags().Lookup(names.SkipPlatform) + require.NotNil(t, visible) + assert.False(t, visible.Hidden) +} diff --git a/desktop/e2e/fixtures/mock-devsy.cjs b/desktop/e2e/fixtures/mock-devsy.cjs index 2a92afe0bf..4e39f3130c 100755 --- a/desktop/e2e/fixtures/mock-devsy.cjs +++ b/desktop/e2e/fixtures/mock-devsy.cjs @@ -2,7 +2,7 @@ "use strict" // Mock devsy binary for e2e tests (cross-platform Node.js version) // Returns canned JSON responses for each subcommand -// Handles --result-format json, --skip-pro, and other flags the app sends +// Handles --result-format json, --skip-platform, --skip-pro, and other flags the app sends // Persists state to a JSON file so provider/workspace CRUD works across calls const fs = require("node:fs") @@ -206,7 +206,12 @@ function parseArgs(args) { i += 2 continue } - if (arg === "--skip-pro" || arg === "--force" || arg.startsWith("--use=")) { + if ( + arg === "--skip-platform" || + arg === "--skip-pro" || + arg === "--force" || + arg.startsWith("--use=") + ) { i++ continue } diff --git a/desktop/src/main/__tests__/cli.test.ts b/desktop/src/main/__tests__/cli.test.ts index f5467b2cd5..e06dbcfc4f 100644 --- a/desktop/src/main/__tests__/cli.test.ts +++ b/desktop/src/main/__tests__/cli.test.ts @@ -429,7 +429,7 @@ describe("CliRunner", () => { const result = await cli.run<{ id: string }[]>([ "workspace", "list", - "--skip-pro", + "--skip-platform", ]) expect(result).toEqual([{ id: "ws-1" }]) expect(mockExecFile).toHaveBeenCalledWith( @@ -437,7 +437,7 @@ describe("CliRunner", () => { [ "workspace", "list", - "--skip-pro", + "--skip-platform", "--log-level", "info", "--result-format", diff --git a/pkg/clihelp/help_test.go b/pkg/clihelp/help_test.go index d2791ef358..c751cc3111 100644 --- a/pkg/clihelp/help_test.go +++ b/pkg/clihelp/help_test.go @@ -24,7 +24,7 @@ func newTestRoot(t *testing.T) *cobra.Command { noop := func(*cobra.Command, []string) {} ws := &cobra.Command{Use: "workspace", Short: "Manage workspaces"} list := &cobra.Command{Use: "list", Short: "List workspaces", Run: noop} - list.Flags().Bool("skip-pro", false, "Don't list pro workspaces") + list.Flags().Bool("skip-platform", false, "Don't list platform workspaces") ws.AddCommand(list) root.AddCommand(ws) root.AddCommand(&cobra.Command{Use: "loose", Short: "A loose command", Run: noop}) @@ -94,7 +94,7 @@ func TestRender_LeafSeparatesLocalFromGlobal(t *testing.T) { out := renderHelp(t, newTestRoot(t), "workspace", "list") assert.Contains(t, out, "devsy workspace list [flags]") - assert.Contains(t, sectionBody(t, out, "OPTIONS:"), "--skip-pro") + assert.Contains(t, sectionBody(t, out, "OPTIONS:"), "--skip-platform") assert.Contains(t, sectionBody(t, out, "GLOBAL OPTIONS:"), "--provider") // A leaf has no subcommands, so the footer hint would be a dead end. assert.NotContains(t, out, "for more information about a subcommand") diff --git a/pkg/flags/names/names.go b/pkg/flags/names/names.go index fd97ef6dd0..f30a252c4b 100644 --- a/pkg/flags/names/names.go +++ b/pkg/flags/names/names.go @@ -61,7 +61,8 @@ const ( Reset = "reset" Secret = "secret" SecretsFile = "secrets-file" - SkipPro = "skip-pro" + SkipPlatform = "skip-platform" + SkipProAlias = "skip-pro" Source = "source" UpdateRemoteUserUID = "update-remote-user-uid" UserEnvProbe = "user-env-probe" diff --git a/pkg/flags/names/names_test.go b/pkg/flags/names/names_test.go index 689a61ef94..06ae0068cd 100644 --- a/pkg/flags/names/names_test.go +++ b/pkg/flags/names/names_test.go @@ -106,7 +106,8 @@ var wireNames = []struct { {names.Repository, "repository"}, {names.StrictHostKeyChecking, "strict-host-key-checking"}, {names.InstallScript, "install-script"}, - {names.SkipPro, "skip-pro"}, + {names.SkipPlatform, "skip-platform"}, + {names.SkipProAlias, "skip-pro"}, {names.ContainerStatus, "container-status"}, {names.WorkspaceID, "workspace-id"}, {names.MachineID, "machine-id"},