diff options
| author | ewy <ewy0@protonmail.com> | 2026-06-01 18:47:44 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-06-01 18:47:44 +0200 |
| commit | 46d032cd21b0e8e2c94a32333d3805ec76980cca (patch) | |
| tree | fbb8aed5c5a501aca1309f62a9d4440ca949ce4c /man/data.go | |
| parent | 7585a488b7b1e1812f7ebf50107139e2fd65f035 (diff) | |
add man(1) generation
Diffstat (limited to 'man/data.go')
| -rw-r--r-- | man/data.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/man/data.go b/man/data.go new file mode 100644 index 0000000..322da8f --- /dev/null +++ b/man/data.go @@ -0,0 +1,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, + } +} |
