diff --git a/internal/commands/ipaddress/show.go b/internal/commands/ipaddress/show.go index 1dffc1136..28f3a427d 100644 --- a/internal/commands/ipaddress/show.go +++ b/internal/commands/ipaddress/show.go @@ -47,7 +47,11 @@ func (s *showCommand) Execute(exec commands.Executor, arg string) (output.Output {Title: "Family:", Key: "access", Value: ipAddress.Family}, {Title: "Part of Plan:", Key: "access", Value: ipAddress.PartOfPlan, Format: output.BoolFormat}, {Title: "PTR Record:", Key: "access", Value: ipAddress.PTRRecord}, - {Title: "Server UUID:", Key: "access", Value: ipAddress.ServerUUID}, + { + Title: "Server UUID:", + Key: "access", Value: ipAddress.ServerUUID, + Color: ui.DefaultUUUIDColours, + }, {Title: "MAC:", Key: "credits", Value: ipAddress.MAC}, {Title: "Floating:", Key: "credits", Value: ipAddress.Floating, Format: output.BoolFormat}, {Title: "Zone:", Key: "zone", Value: ipAddress.Zone}, diff --git a/internal/commands/network/list.go b/internal/commands/network/list.go index 207df372b..b045444b1 100644 --- a/internal/commands/network/list.go +++ b/internal/commands/network/list.go @@ -95,7 +95,7 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou Columns: []output.TableColumn{ {Key: "uuid", Header: "UUID", Color: ui.DefaultUUUIDColours}, {Key: "name", Header: "Name"}, - {Key: "router", Header: "Router"}, + {Key: "router", Header: "Router", Color: ui.DefaultUUUIDColours}, {Key: "type", Header: "Type"}, {Key: "zone", Header: "Zone"}, }, diff --git a/internal/commands/network/list_test.go b/internal/commands/network/list_test.go index 681d6691b..913cd76c8 100644 --- a/internal/commands/network/list_test.go +++ b/internal/commands/network/list_test.go @@ -105,7 +105,7 @@ func createTable(networks []upcloud.Network) output.Table { Columns: []output.TableColumn{ {Header: "UUID", Key: "uuid", Hidden: false, Color: ui.DefaultUUUIDColours}, {Header: "Name", Key: "name", Hidden: false}, - {Header: "Router", Key: "router", Hidden: false}, + {Header: "Router", Key: "router", Hidden: false, Color: ui.DefaultUUUIDColours}, {Header: "Type", Key: "type", Hidden: false}, {Header: "Zone", Key: "zone", Hidden: false}, }, diff --git a/internal/commands/network/show.go b/internal/commands/network/show.go index 57be99f5c..b3b15cd34 100644 --- a/internal/commands/network/show.go +++ b/internal/commands/network/show.go @@ -40,24 +40,30 @@ func (s *showCommand) Execute(exec commands.Executor, arg string) (output.Output if err != nil { return nil, err } - commonSection := output.CombinedSection{Key: "", Title: "", Contents: output.Details{ - Sections: []output.DetailSection{ - { - Title: "Common", - Rows: []output.DetailRow{ - {Title: "UUID:", Key: "uuid", Value: network.UUID, Color: ui.DefaultUUUIDColours}, - {Title: "Name:", Key: "name", Value: network.Name}, - {Title: "Router:", Key: "router", Value: network.Router}, - {Title: "Type:", Key: "type", Value: network.Type}, - {Title: "Zone:", Key: "zone", Value: network.Zone}, + + combined := output.Combined{ + output.CombinedSection{ + Key: "", + Title: "", + Contents: output.Details{ + Sections: []output.DetailSection{ + { + Title: "Common", + Rows: []output.DetailRow{ + {Title: "UUID:", Key: "uuid", Value: network.UUID, Color: ui.DefaultUUUIDColours}, + {Title: "Name:", Key: "name", Value: network.Name}, + {Title: "Router:", Key: "router", Value: network.Router}, + {Title: "Type:", Key: "type", Value: network.Type}, + {Title: "Zone:", Key: "zone", Value: network.Zone}, + }, + }, }, }, }, - }, } - networkRows := make([]output.TableRow, 0) if len(network.IPNetworks) > 0 { + networkRows := make([]output.TableRow, 0) for _, nip := range network.IPNetworks { networkRows = append(networkRows, output.TableRow{ nip.Address, @@ -67,50 +73,52 @@ func (s *showCommand) Execute(exec commands.Executor, arg string) (output.Output strings.Join(nip.DHCPDns, " "), }) } - } - networkSection := output.CombinedSection{ - Key: "ip_networks", - Title: "IP Networks:", - Contents: output.Table{ - Columns: []output.TableColumn{ - {Key: "address", Header: "Address", Color: ui.DefaultAddressColours}, - {Key: "family", Header: "Family"}, - {Key: "dhcp", Header: "DHCP", Format: output.BoolFormat}, - {Key: "dhcp_default_route", Header: "DHCP Def Router", Format: output.BoolFormat}, - {Key: "dhcp_dns", Header: "DHCP DNS"}, + + combined = append(combined, output.CombinedSection{ + Key: "ip_networks", + Title: "IP Networks:", + Contents: output.Table{ + Columns: []output.TableColumn{ + {Key: "address", Header: "Address", Color: ui.DefaultAddressColours}, + {Key: "family", Header: "Family"}, + {Key: "dhcp", Header: "DHCP", Format: output.BoolFormat}, + {Key: "dhcp_default_route", Header: "DHCP Def Router", Format: output.BoolFormat}, + {Key: "dhcp_dns", Header: "DHCP DNS"}, + }, + Rows: networkRows, }, - Rows: networkRows, - }} + }) + } - serverRows := make([]output.TableRow, 0) - for _, server := range network.Servers { - fetched, err := exec.Server().GetServerDetails(&request.GetServerDetailsRequest{UUID: server.ServerUUID}) - if err != nil { - return nil, fmt.Errorf("error getting server %v details: %w", server.ServerUUID, err) + if len(network.Servers) > 0 { + serverRows := make([]output.TableRow, 0) + for _, server := range network.Servers { + fetched, err := exec.Server().GetServerDetails(&request.GetServerDetailsRequest{UUID: server.ServerUUID}) + if err != nil { + return nil, fmt.Errorf("error getting server %v details: %w", server.ServerUUID, err) + } + serverRows = append(serverRows, output.TableRow{ + fetched.UUID, + fetched.Title, + fetched.Hostname, + fetched.State, + }) } - serverRows = append(serverRows, output.TableRow{ - fetched.UUID, - fetched.Title, - fetched.Hostname, - fetched.State, + + combined = append(combined, output.CombinedSection{ + Key: "servers", + Title: "Servers:", + Contents: output.Table{ + Columns: []output.TableColumn{ + {Header: "UUID", Key: "uuid", Color: ui.DefaultUUUIDColours}, + {Header: "Title", Key: "title"}, + {Header: "Hostname", Key: "hostname"}, + {Header: "State", Key: "state"}, + }, + Rows: serverRows, + }, }) } - serverSection := output.CombinedSection{ - Key: "servers", - Title: "Servers:", - Contents: output.Table{ - Columns: []output.TableColumn{ - {Header: "UUID", Key: "uuid", Color: ui.DefaultUUUIDColours}, - {Header: "Title", Key: "title"}, - {Header: "Hostname", Key: "hostname"}, - {Header: "State", Key: "state"}, - }, - Rows: serverRows, - }} - return output.Combined{ - commonSection, - networkSection, - serverSection, - }, nil + return combined, nil } diff --git a/internal/commands/server/list.go b/internal/commands/server/list.go index f2c75d2fc..25dc997ad 100644 --- a/internal/commands/server/list.go +++ b/internal/commands/server/list.go @@ -5,6 +5,7 @@ import ( "github.com/UpCloudLtd/upcloud-cli/internal/commands" "github.com/UpCloudLtd/upcloud-cli/internal/output" + "github.com/UpCloudLtd/upcloud-cli/internal/ui" ) // ListCommand creates the "server list" command @@ -44,7 +45,7 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou return output.Table{ Columns: []output.TableColumn{ - {Key: "uuid", Header: "UUID"}, + {Key: "uuid", Header: "UUID", Color: ui.DefaultUUUIDColours}, {Key: "hostname", Header: "Hostname"}, {Key: "plan", Header: "Plan"}, {Key: "zone", Header: "Zone"}, diff --git a/internal/commands/server/show.go b/internal/commands/server/show.go index cf910c8d0..661cf4461 100644 --- a/internal/commands/server/show.go +++ b/internal/commands/server/show.go @@ -136,7 +136,7 @@ func (s *showCommand) Execute(exec commands.Executor, uuid string) (output.Outpu { Title: "Common", Rows: []output.DetailRow{ - {Title: "UUID:", Key: "uuid", Value: server.UUID}, + {Title: "UUID:", Key: "uuid", Value: server.UUID, Color: ui.DefaultUUUIDColours}, {Title: "Hostname:", Key: "hostname", Value: server.Hostname}, {Title: "Title:", Key: "title", Value: server.Title}, {Title: "Plan:", Key: "plan", Value: planOutput}, @@ -177,7 +177,7 @@ func (s *showCommand) Execute(exec commands.Executor, uuid string) (output.Outpu {Key: "type", Header: "Type"}, {Key: "ip_address", Header: "IP Address"}, {Key: "mac_address", Header: "MAC Address"}, - {Key: "network", Header: "Network"}, + {Key: "network", Header: "Network", Color: ui.DefaultUUUIDColours}, {Key: "flags", Header: "Flags"}, }, Rows: nicRows,