-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus.go
More file actions
87 lines (76 loc) · 1.72 KB
/
Copy pathstatus.go
File metadata and controls
87 lines (76 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
import (
"fmt"
"os"
"os/exec"
"strings"
"github.com/spf13/cobra"
)
var statusCmd = &cobra.Command{
Use: "status",
Short: "Show container/volume status",
RunE: runStatus,
}
func init() {
rootCmd.AddCommand(statusCmd)
}
func runStatus(cmd *cobra.Command, args []string) error {
cfg := resolveConfig()
fmt.Println()
fmt.Println("Install paths:")
fmt.Printf(" OSS_BACK2BASE_HOME = %s\n", cfg.Home)
fmt.Printf(" OSS_BACK2BASE_CONFIG = %s\n", cfg.ConfigDir)
fmt.Printf(" Binary = %s (v%s)\n", execPath(), version)
fmt.Println()
fmt.Println("Env file:")
if _, err := os.Stat(cfg.EnvFile); err == nil {
fmt.Printf(" %s (present)\n", cfg.EnvFile)
} else {
fmt.Printf(" (no env file at %s)\n", cfg.EnvFile)
}
fmt.Println()
// Images
fmt.Println("Image:")
out, err := exec.Command("docker", "images",
"--format", " {{.Repository}}:{{.Tag}}\t{{.Size}}\t{{.CreatedSince}}").Output()
if err == nil {
found := false
for _, line := range strings.Split(string(out), "\n") {
if strings.Contains(line, "claude") {
fmt.Println(line)
found = true
}
}
if !found {
fmt.Println(" (not built)")
}
} else {
fmt.Println(" (docker not available)")
}
fmt.Println()
// Containers
fmt.Println("Running containers:")
out, err = exec.Command("docker", "ps",
"--format", " {{.Names}}\t{{.Status}}").Output()
if err == nil {
found := false
for _, line := range strings.Split(string(out), "\n") {
if strings.Contains(line, "claude") {
fmt.Println(line)
found = true
}
}
if !found {
fmt.Println(" (none)")
}
}
fmt.Println()
return nil
}
func execPath() string {
p, err := os.Executable()
if err != nil {
return "(unknown)"
}
return p
}