@@ -16,13 +16,13 @@ func newListCommand() *cli.Command {
1616 Name : "list" ,
1717 Aliases : []string {"ls" },
1818 Usage : "List your sandboxes" ,
19- Description : `Show your sandboxes. By default only running ones are shown.
19+ Description : `Show your sandboxes. By default active ones are shown (running, paused, pausing, resuming, forking) .
2020
2121Examples:
22- # Running sandboxes
22+ # Active sandboxes (running, paused, pausing, resuming, forking)
2323 createos sandbox list
2424
25- # Every sandbox, including paused / destroyed / failed rows
25+ # Every sandbox, including destroyed / failed rows
2626 createos sandbox list --all
2727
2828 # Just one status
@@ -43,12 +43,12 @@ Examples:
4343 },
4444 & cli.StringFlag {
4545 Name : "status" ,
46- Usage : "Show only sandboxes in this state (running | creating | paused | destroyed | failed)" ,
46+ Usage : "Show only sandboxes in this state (running | paused | pausing | resuming | forking | creating | destroyed | failed)" ,
4747 },
4848 & cli.BoolFlag {
4949 Name : "all" ,
5050 Aliases : []string {"a" },
51- Usage : "Show sandboxes in every state, not just running ones" ,
51+ Usage : "Show sandboxes in every state, not just active ones" ,
5252 },
5353 & cli.BoolFlag {
5454 Name : "quiet" ,
@@ -66,12 +66,11 @@ func runList(c *cli.Context) error {
6666 return fmt .Errorf ("you're not signed in — run 'createos login' to get started" )
6767 }
6868
69- // Default: running only. --all clears the filter. --status overrides both.
70- status := "running"
69+ // Default: active statuses only. --all clears the filter. --status overrides both.
70+ status := ""
71+ showAll := c .Bool ("all" )
7172 if explicit := c .String ("status" ); explicit != "" {
7273 status = explicit
73- } else if c .Bool ("all" ) {
74- status = ""
7574 }
7675
7776 rows , _ , err := client .ListSandboxes (c .Context , api.ListSandboxesOpts {
@@ -83,6 +82,24 @@ func runList(c *cli.Context) error {
8382 return err
8483 }
8584
85+ // When neither --all nor --status is given, keep only active statuses.
86+ if ! showAll && status == "" {
87+ activeStatuses := map [string ]bool {
88+ "running" : true ,
89+ "paused" : true ,
90+ "pausing" : true ,
91+ "resuming" : true ,
92+ "forking" : true ,
93+ }
94+ filtered := rows [:0 ]
95+ for _ , r := range rows {
96+ if activeStatuses [r .Status ] {
97+ filtered = append (filtered , r )
98+ }
99+ }
100+ rows = filtered
101+ }
102+
86103 sort .SliceStable (rows , func (i , j int ) bool {
87104 return rows [i ].CreatedAt .After (rows [j ].CreatedAt )
88105 })
@@ -98,9 +115,12 @@ func runList(c *cli.Context) error {
98115
99116 output .Render (c , rows , func () {
100117 if len (rows ) == 0 {
101- if status == "" {
118+ switch {
119+ case status == "" && showAll :
102120 fmt .Println ("You don't have any sandboxes yet." )
103- } else {
121+ case status == "" :
122+ fmt .Println ("You don't have any active sandboxes." )
123+ default :
104124 fmt .Printf ("You don't have any %s sandboxes.\n " , status )
105125 }
106126 fmt .Println ()
0 commit comments