From ebae3fe8a43a7f6af89099e4b26b82b1df09b5b2 Mon Sep 17 00:00:00 2001 From: MDietermann Date: Tue, 14 Apr 2026 21:05:30 +0200 Subject: [PATCH] feat(cmd): add version subcommand with ldflag-injected build info --- cmd/archduino/main.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cmd/archduino/main.go b/cmd/archduino/main.go index a60db2b..233b34a 100644 --- a/cmd/archduino/main.go +++ b/cmd/archduino/main.go @@ -38,7 +38,11 @@ import ( "gitlab.hive-brain.de/MDietermann/Archduino/internal/tui/wizard" ) -var version = "dev" +var ( + version = "dev" + commit = "none" + date = "unknown" +) // buildRegistry constructs a module registry populated with all Plan 3a // modules, wired against the provided config and platform dependencies. @@ -85,6 +89,7 @@ func main() { root.AddCommand(newThemeCmd()) root.AddCommand(newNewCmd()) root.AddCommand(newDoctorCmd()) + root.AddCommand(newVersionCmd()) // Wire SIGINT/SIGTERM to a cancellable context so long-running phases // (engine.Run, sudo keepalive) observe the cancellation promptly. @@ -422,3 +427,13 @@ func newDoctorCmd() *cobra.Command { cmd.Flags().StringVar(&overlayPath, "overlay", "", "path to overlay.yaml") return cmd } + +func newVersionCmd() *cobra.Command { + return &cobra.Command{ + Use: "version", + Short: "Print version, commit, and build date", + Run: func(cmd *cobra.Command, args []string) { + fmt.Printf("archduino %s\ncommit: %s\ndate: %s\n", version, commit, date) + }, + } +}