feat(cmd): add version subcommand with ldflag-injected build info
This commit is contained in:
@@ -38,7 +38,11 @@ import (
|
|||||||
"gitlab.hive-brain.de/MDietermann/Archduino/internal/tui/wizard"
|
"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
|
// buildRegistry constructs a module registry populated with all Plan 3a
|
||||||
// modules, wired against the provided config and platform dependencies.
|
// modules, wired against the provided config and platform dependencies.
|
||||||
@@ -85,6 +89,7 @@ func main() {
|
|||||||
root.AddCommand(newThemeCmd())
|
root.AddCommand(newThemeCmd())
|
||||||
root.AddCommand(newNewCmd())
|
root.AddCommand(newNewCmd())
|
||||||
root.AddCommand(newDoctorCmd())
|
root.AddCommand(newDoctorCmd())
|
||||||
|
root.AddCommand(newVersionCmd())
|
||||||
|
|
||||||
// Wire SIGINT/SIGTERM to a cancellable context so long-running phases
|
// Wire SIGINT/SIGTERM to a cancellable context so long-running phases
|
||||||
// (engine.Run, sudo keepalive) observe the cancellation promptly.
|
// (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")
|
cmd.Flags().StringVar(&overlayPath, "overlay", "", "path to overlay.yaml")
|
||||||
return cmd
|
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)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user