-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmd_list.go
More file actions
51 lines (44 loc) · 1.12 KB
/
Copy pathcmd_list.go
File metadata and controls
51 lines (44 loc) · 1.12 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
package main
import (
"flag"
"fmt"
"io"
)
var listHelp = &helpNode{
cmd: "list",
synopsis: "List profiles' information.",
usage: func(w io.Writer) {
cmdTitle(w, false, "list [-a|-v]")
cmdUsage(w, "Without any options, print current profile's brief details.\n"+
"-a: Print with all profile's brief details.\n"+
"-v: Print current profile's full information.\n")
},
}
func listHandler(args []string, data interface{}) (int, error) {
var verbose, all bool
flagSet := flag.NewFlagSet("list", flag.ExitOnError)
flagSet.BoolVar(&verbose, "v", false, "print with more information.")
flagSet.BoolVar(&all, "a", false, "print all profiles.")
flagSet.Parse(args)
printAdditional := func(p *Profile) {
version, err := kernelFullVersion(p)
if err == nil {
fmt.Println(" Version :", version)
}
}
if !all {
p := gConfig.Profiles[gConfig.Current]
printProfile(p, verbose, true, gConfig.Current)
if verbose {
printAdditional(p)
}
return 0, nil
}
for i, p := range gConfig.Profiles {
printProfile(p, verbose, gConfig.Current == i, i)
if verbose {
printAdditional(p)
}
}
return 0, nil
}