Skip to content

Commit 1d3e117

Browse files
authored
cli: add more details to status command (#581)
* instance details in status command * hide additional infromation behind flag * add network driver to additional details
1 parent 0f711c0 commit 1d3e117

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

app/app.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/abiosoft/colima/environment/vm/lima"
2222
"github.com/abiosoft/colima/environment/vm/lima/limautil"
2323
"github.com/abiosoft/colima/util"
24+
"github.com/docker/go-units"
2425
log "github.com/sirupsen/logrus"
2526
)
2627

@@ -30,7 +31,7 @@ type App interface {
3031
Stop(force bool) error
3132
Delete() error
3233
SSH(layer bool, args ...string) error
33-
Status() error
34+
Status(extended bool) error
3435
Version() error
3536
Runtime() (string, error)
3637
Kubernetes() (environment.Container, error)
@@ -301,7 +302,7 @@ func (c colimaApp) SSH(layer bool, args ...string) error {
301302
return cli.CommandInteractive("ssh", args...).Run()
302303
}
303304

304-
func (c colimaApp) Status() error {
305+
func (c colimaApp) Status(extended bool) error {
305306
ctx := context.Background()
306307
if !c.guest.Running(ctx) {
307308
return fmt.Errorf("%s is not running", config.CurrentProfile().DisplayName)
@@ -340,6 +341,17 @@ func (c colimaApp) Status() error {
340341
log.Println("kubernetes: enabled")
341342
}
342343

344+
// additional details
345+
if extended {
346+
log.Println("networkDriver:", conf.Network.Driver)
347+
348+
if inst, err := limautil.Instance(); err == nil {
349+
log.Println("cpu:", inst.CPU)
350+
log.Println("mem:", units.BytesSize(float64(inst.Memory)))
351+
log.Println("disk:", units.BytesSize(float64(inst.Disk)))
352+
}
353+
}
354+
343355
return nil
344356
}
345357

cmd/status.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@ import (
55
"github.com/spf13/cobra"
66
)
77

8+
var statusCmdArgs struct {
9+
extended bool
10+
}
11+
812
// statusCmd represents the status command
913
var statusCmd = &cobra.Command{
1014
Use: "status [profile]",
1115
Short: "show the status of Colima",
1216
Long: `Show the status of Colima`,
1317
Args: cobra.MaximumNArgs(1),
1418
RunE: func(cmd *cobra.Command, args []string) error {
15-
return newApp().Status()
19+
return newApp().Status(statusCmdArgs.extended)
1620
},
1721
}
1822

1923
func init() {
2024
root.Cmd().AddCommand(statusCmd)
25+
26+
statusCmd.Flags().BoolVarP(&statusCmdArgs.extended, "extended", "e", false, "include additional details")
2127
}

0 commit comments

Comments
 (0)