aboutsummaryrefslogtreecommitdiff
path: root/cmd/flakeinfo/main.go
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2024-01-22 08:12:11 -0800
committerFranck Cuny <franck@fcuny.net>2024-01-22 08:12:11 -0800
commit15ad4921327190a49e982c2249d2693d37fde4b1 (patch)
tree31a8fe7bbacca5aa74b9587fd49910ecdbd2ac0e /cmd/flakeinfo/main.go
parentadd more commands to devshell's menu (diff)
downloadinfra-15ad4921327190a49e982c2249d2693d37fde4b1.tar.gz
add build information to `flake-info`
Diffstat (limited to 'cmd/flakeinfo/main.go')
-rw-r--r--cmd/flakeinfo/main.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/cmd/flakeinfo/main.go b/cmd/flakeinfo/main.go
index d41f321..8c1960c 100644
--- a/cmd/flakeinfo/main.go
+++ b/cmd/flakeinfo/main.go
@@ -7,16 +7,38 @@ import (
"os"
"time"
+ "github.com/fcuny/world/internal/version"
"github.com/fcuny/world/pkg/flake/lock"
)
+const usage = `Usage:
+ flake-info [flake.lock]
+
+Options:
+ -v, --version Print version information
+ -h, --help Print this message
+`
+
func main() {
- var flakeLockPath string
+ flag.Usage = func() { fmt.Fprintf(os.Stderr, "%s\n", usage) }
+
+ var (
+ flakeLockPath string
+ versionFlag bool
+ )
flag.StringVar(&flakeLockPath, "flake-lock", "flake.lock", "path to the flake lock file")
+ flag.BoolVar(&versionFlag, "version", false, "Print version information")
+ flag.BoolVar(&versionFlag, "v", false, "Print version information")
flag.Parse()
+ if versionFlag {
+ information := version.VersionAndBuildInfo()
+ fmt.Println(information)
+ return
+ }
+
if _, err := os.Stat(flakeLockPath); err != nil {
if errors.Is(err, os.ErrNotExist) {
fmt.Fprintf(os.Stderr, "%s does not exists\n", flakeLockPath)