mydev/cmd/docker.go
Victor Abrell 47bb2d3a69 Use Gitea module path, add MIT license
Set module to git.abrell.se/victor/mydev so it installs from the
private Gitea host, and add an MIT LICENSE.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 14:41:20 +02:00

39 lines
776 B
Go

package cmd
import (
"context"
"fmt"
"os"
"text/tabwriter"
"git.abrell.se/victor/mydev/internal/checks"
"github.com/spf13/cobra"
)
var dockerCmd = &cobra.Command{
Use: "docker",
Short: "List docker containers and their status",
Run: func(cmd *cobra.Command, args []string) {
list, errMsg := checks.Containers(context.Background())
if errMsg != "" {
fmt.Printf("✗ docker error: %s\n", errMsg)
os.Exit(1)
}
if len(list) == 0 {
fmt.Println("no containers")
return
}
w := tabwriter.NewWriter(os.Stdout, 0, 2, 2, ' ', 0)
fmt.Fprintln(w, "NAME\tSTATE\tSTATUS\tIMAGE")
for _, c := range list {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", c.Name, c.State, c.Status, c.Image)
}
w.Flush()
},
}
func init() {
rootCmd.AddCommand(dockerCmd)
}