-
Notifications
You must be signed in to change notification settings - Fork 51
/
status_cmd.go
58 lines (54 loc) · 1.24 KB
/
status_cmd.go
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
package app
import (
"fmt"
"github.com/cashapp/hermit"
"github.com/cashapp/hermit/errors"
"github.com/cashapp/hermit/ui"
)
type statusCmd struct{}
func (s *statusCmd) Run(l *ui.UI, env *hermit.Env) error {
envars, err := env.Envars(l, false)
if err != nil {
return errors.WithStack(err)
}
pkgs, err := env.ListInstalled(l)
if err != nil {
return errors.WithStack(err)
}
fmt.Println("Sources:")
sources, err := env.Sources(l)
if err != nil {
return errors.WithStack(err)
}
for _, source := range sources {
fmt.Printf(" %s\n", source)
}
fmt.Println("Packages:")
for _, pkg := range pkgs {
fmt.Printf(" %s\n", pkg)
if l.WillLog(ui.LevelDebug) {
fmt.Printf(" Description: %s\n", pkg.Description)
fmt.Printf(" Root: %s\n", pkg.Root)
fmt.Printf(" Source: %s\n", pkg.Source)
bins, err := pkg.ResolveBinaries()
if err != nil {
return errors.WithStack(err)
}
fmt.Println(" Binaries:")
for _, bin := range bins {
fmt.Printf(" %s\n", bin)
}
if len(pkg.Env) != 0 {
fmt.Printf(" Environment:\n")
for _, op := range pkg.Env {
fmt.Printf(" %s\n", op)
}
}
}
}
fmt.Println("Environment:")
for _, env := range envars {
fmt.Printf(" %s\n", env)
}
return nil
}