From e195ae8d82b145d38b46cb2c009af3785794d3ab Mon Sep 17 00:00:00 2001 From: sofq Date: Wed, 15 Apr 2026 21:14:16 +0700 Subject: [PATCH] fix: workflow create command shadowed by generated create Move generated.RegisterAll() and mergeCommand() from init() to Execute() so that all package-level init functions have completed before merging. Previously, root.go's init ran before workflow.go's init (alphabetical order), so mergeCommand saw an empty workflowCmd and copied the generated "create" (raw Jira workflow API) into it. The hand-written "create" (convenience issue creation) was then added as a duplicate and Cobra returned the generated one first. --- cmd/root.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 319cab4..7e084a6 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -229,14 +229,6 @@ func init() { // Override --version template to output JSON. rootCmd.SetVersionTemplate(`{"version":"{{.Version}}"}` + "\n") - // Register generated commands first, then replace version/workflow parents - // with hand-written ones while preserving generated subcommands. - generated.RegisterAll(rootCmd) - - // Merge hand-written version/workflow with their generated subcommands. - mergeCommand(rootCmd, versionCmd) - mergeCommand(rootCmd, workflowCmd) - rootCmd.AddCommand(configureCmd) rootCmd.AddCommand(rawCmd) rootCmd.AddCommand(watchCmd) @@ -272,6 +264,15 @@ func RootCommand() *cobra.Command { // Execute runs the root command and returns an exit code. func Execute() int { + // Register generated commands, then merge hand-written parents + // (version, workflow) with their generated subcommands. + // This runs here rather than in init() so that all package-level + // init() functions have completed and hand-written subcommands + // (e.g. workflow create) are already registered. + generated.RegisterAll(rootCmd) + mergeCommand(rootCmd, versionCmd) + mergeCommand(rootCmd, workflowCmd) + // Evict stale cache entries in the background so it never delays command execution. go cache.Evict()