Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions cmd/workspace/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
type ListCmd struct {
*flags.GlobalFlags

SkipPro bool
SkipPlatform bool
}

// NewListCmd creates a new destroy command.
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
48 changes: 48 additions & 0 deletions cmd/workspace/list_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
9 changes: 7 additions & 2 deletions desktop/e2e/fixtures/mock-devsy.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions desktop/src/main/__tests__/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,15 @@ describe("CliRunner", () => {
const result = await cli.run<{ id: string }[]>([
"workspace",
"list",
"--skip-pro",
"--skip-platform",
])
expect(result).toEqual([{ id: "ws-1" }])
expect(mockExecFile).toHaveBeenCalledWith(
"/usr/local/bin/devsy",
[
"workspace",
"list",
"--skip-pro",
"--skip-platform",
"--log-level",
"info",
"--result-format",
Expand Down
4 changes: 2 additions & 2 deletions pkg/clihelp/help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion pkg/flags/names/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion pkg/flags/names/names_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
Loading