@@ -51,9 +51,11 @@ var groupShowCmd = &cobra.Command{
5151 version := group .Version
5252 fmt .Printf ("Locations: %s\n " , formatLocations (group .Locations , group .Primary ))
5353 fmt .Printf ("Version: %s\n " , internal .Emph (version ))
54+ fmt .Printf ("Status: %s\n " , aggregateGroupStatus (group ))
5455 return nil
5556 },
5657}
58+
5759var groupsListCmd = & cobra.Command {
5860 Use : "list" ,
5961 Short : "List databases groups" ,
@@ -71,7 +73,7 @@ var groupsListCmd = &cobra.Command{
7173 return err
7274 }
7375
74- printTable ([]string {"Name" , "Locations" , "Version" , "Sleeping " }, groupsTable (groups ))
76+ printTable ([]string {"Name" , "Locations" , "Version" , "Status " }, groupsTable (groups ))
7577 return nil
7678 },
7779}
@@ -215,12 +217,37 @@ func destroyGroup(client *turso.Client, name string) error {
215217func groupsTable (groups []turso.Group ) [][]string {
216218 var data [][]string
217219 for _ , group := range groups {
218- row := []string {group .Name , formatLocations (group .Locations , group .Primary ), group .Version , formatBool (group . Archived )}
220+ row := []string {group .Name , formatLocations (group .Locations , group .Primary ), group .Version , aggregateGroupStatus (group )}
219221 data = append (data , row )
220222 }
221223 return data
222224}
223225
226+ func aggregateGroupStatus (group turso.Group ) string {
227+ status := "Healthy"
228+ if group .Archived {
229+ return "Sleeping 💤"
230+ }
231+ allIdle := true
232+ for _ , locationStatus := range group .Status .Locations {
233+ if group .Primary == locationStatus .Name && locationStatus .Status == "down" {
234+ status = "Unhealthy"
235+ break
236+ }
237+ if locationStatus .Status != "stopped" {
238+ allIdle = false
239+ }
240+ if locationStatus .Status == "down" {
241+ allIdle = false
242+ status = "Degraded"
243+ }
244+ }
245+ if allIdle {
246+ status = "Idle"
247+ }
248+ return status
249+ }
250+
224251func getGroups (client * turso.Client , fresh ... bool ) ([]turso.Group , error ) {
225252 skipCache := len (fresh ) > 0 && fresh [0 ]
226253 if cached := getGroupsCache (client .Org ); ! skipCache && cached != nil {
0 commit comments