-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
env.go
87 lines (70 loc) · 1.71 KB
/
env.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
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"
"fyne.io/fyne"
"github.com/lucor/goinfo"
"github.com/lucor/goinfo/format"
"github.com/lucor/goinfo/report"
)
const (
fyneModule = "fyne.io/fyne"
)
// Declare conformity to command interface
var _ command = (*env)(nil)
type env struct {
}
func (v *env) addFlags() {
}
func (v *env) printHelp(indent string) {
fmt.Println(indent, "The env command prints the Fyne module and environment information")
fmt.Println(indent, "Command usage: fyne env")
}
func (v *env) main() {
workDir, err := os.Getwd()
if err != nil {
fmt.Fprintln(os.Stderr, fmt.Errorf("could not get the path for the current working dir: %v", err))
os.Exit(1)
}
reporters := []goinfo.Reporter{
&fyneReport{GoMod: &report.GoMod{WorkDir: workDir, Module: fyneModule}},
&report.GoVersion{},
&report.GoEnv{Filter: []string{"GOOS", "GOARCH", "CGO_ENABLED", "GO111MODULE"}},
}
err = goinfo.Write(os.Stdout, reporters, &format.Text{})
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}
func (v *env) run(args []string) {
if len(args) != 0 {
fyne.LogError("Unexpected parameter after flags", nil)
return
}
v.main()
}
// fyneReport defines a custom report for fyne
type fyneReport struct {
*report.GoMod
}
// Summary returns the summary for the fyneReport
func (r *fyneReport) Summary() string {
return "Fyne info"
}
// Info returns the collected info
func (r *fyneReport) Info() (goinfo.Info, error) {
info, err := r.GoMod.Info()
if err != nil {
return info, err
}
// remove info for the report
delete(info, "module")
versionCmd := &version{}
cliVersion, err := versionCmd.get()
if err != nil {
cliVersion = err.Error()
}
info["cli_version"] = cliVersion
return info, nil
}