mydev/cmd/status.go
Victor Abrell 7140397a13 Initial commit: MyDev dev-environment TUI
CLI + live dashboard wrapping aws/docker/git/awsmfa for local dev:
AWS MFA auth status + expiry, dev compose stack control, container
drift vs the dev repo, git repo status, prod-data and DB-access tools.
Config-driven (~/.config/mydev/config.yaml). Dashboard runs commands
via a command palette with captured/interactive modes.

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

80 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package cmd
import (
"context"
"fmt"
"os"
"text/tabwriter"
"mydev/internal/checks"
"mydev/internal/config"
"github.com/spf13/cobra"
)
var statusCmd = &cobra.Command{
Use: "status",
Short: "One-shot overview: AWS auth + docker + repos",
Run: func(cmd *cobra.Command, args []string) {
cfg, err := config.Load()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
ctx := context.Background()
// AWS
if awsmfa, err := cfg.AWSMFA(); err != nil {
fmt.Printf("AWS %s\n", err)
} else {
a := checks.AWSAuth(ctx, awsmfa)
switch {
case a.Authed:
fmt.Printf("AWS ✓ authed %s\n", a.Detail)
case a.Err != "":
fmt.Printf("AWS ✗ awsmfa error: %s\n", a.Err)
default:
fmt.Printf("AWS ✗ re-auth needed — run 'mydev auth login'\n")
}
}
// Docker
cs, derr := checks.Containers(ctx)
if derr != "" {
fmt.Printf("DOCKER ✗ %s\n", derr)
} else {
running := 0
for _, c := range cs {
if c.State == "running" {
running++
}
}
fmt.Printf("DOCKER %d running / %d total\n", running, len(cs))
}
// Repos
rs, rerr := checks.ReposMulti(ctx, cfg.ReposRoots)
if rerr != "" {
fmt.Printf("REPOS ✗ %s\n", rerr)
} else {
fmt.Println("REPOS")
w := tabwriter.NewWriter(os.Stdout, 0, 2, 2, ' ', 0)
for _, r := range rs {
flag := "clean"
if r.Dirty {
flag = "dirty"
}
if r.Err != "" {
flag = "err: " + r.Err
}
fmt.Fprintf(w, " %s\t%s\t%s\n", r.Name, r.Branch, flag)
}
w.Flush()
}
},
}
func init() {
rootCmd.AddCommand(statusCmd)
}