feat: IMP-13 — add version command with build-time variables

opal version (and opal --version) prints version, commit, and build
date. Values are set via ldflags at build time; defaults to "dev" for
local builds. VERSION file added at 0.1.0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-19 13:38:25 +01:00
parent f57baee6bc
commit 779da6ddfd
3 changed files with 34 additions and 2 deletions
+7 -2
View File
@@ -32,6 +32,7 @@ var commandNames = []string{
"add", "done", "modify", "delete",
"start", "stop", "count", "projects", "tags",
"info", "edit", "server", "sync", "reports", "setup",
"version",
}
// Report names (dynamically populated)
@@ -47,9 +48,9 @@ var commandsWithModifiers = map[string]bool{
}
var rootCmd = &cobra.Command{
Use: "opal",
Use: "opal [filter] [command|report] [modifiers]",
Short: "Opal task manager - taskwarrior-inspired CLI task management",
Long: `Opal is a powerful command-line task manager inspired by taskwarrior.
Long: `Opal is a powerful command-line task manager.
It supports filtering, tags, priorities, projects, and recurring tasks.`,
Run: func(cmd *cobra.Command, args []string) {
// Default behavior: run configured default report (defaults to "list")
@@ -218,6 +219,10 @@ func init() {
rootCmd.AddCommand(infoCmd)
rootCmd.AddCommand(editCmd)
rootCmd.AddCommand(reportsCmd)
rootCmd.AddCommand(versionCmd)
// Enable --version flag on root command
rootCmd.Version = Version
// Add report commands dynamically
reportCommands := CreateReportCommands()