blob: 322da8f9bab156cc1633b2461c483ec5018316fe (
plain)
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
|
package main
import (
_ "embed"
_ "github.com/ewy1/pik/flags"
"github.com/ewy1/pik/spool"
"github.com/spf13/pflag"
"runtime"
"runtime/debug"
"time"
)
//go:embed version.txt
var version string
type ManData struct {
Flags []pflag.Flag
Now string
Revision string
Runtime string
Version string
ExitCodes map[int]*spool.ExitCode
}
func NewData() ManData {
var flags []pflag.Flag
pflag.Parse()
pflag.VisitAll(func(flag *pflag.Flag) {
flags = append(flags, *flag)
})
info, ok := debug.ReadBuildInfo()
if !ok {
_, _ = spool.Panic(spool.NoDebugInfo, "could not read debug info\n")
}
return ManData{
Flags: flags,
Now: time.Now().Format(time.DateTime),
Runtime: runtime.Version(),
Version: version,
Revision: info.Main.Version,
ExitCodes: spool.CodeMap,
}
}
|