-
Notifications
You must be signed in to change notification settings - Fork 296
fix(cli): standardize --help flag descriptions and "agentic workflow" terminology #20375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| //go:build !integration | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| // TestHelpFlagConsistency verifies that all commands have consistent --help flag | ||
| // descriptions starting with "Show help for gh aw" (matching the root command). | ||
| func TestHelpFlagConsistency(t *testing.T) { | ||
| var checkCmd func(cmd *cobra.Command) | ||
| checkCmd = func(cmd *cobra.Command) { | ||
| t.Run("command "+cmd.CommandPath()+" has consistent help flag", func(t *testing.T) { | ||
| cmd.InitDefaultHelpFlag() | ||
| f := cmd.Flags().Lookup("help") | ||
| if f == nil { | ||
| t.Skip("Command has no help flag") | ||
| } | ||
| want := "Show help for gh aw" | ||
| if !strings.HasPrefix(f.Usage, want) { | ||
| t.Errorf("Command %q help flag Usage = %q, want prefix %q", cmd.CommandPath(), f.Usage, want) | ||
| } | ||
| }) | ||
| for _, sub := range cmd.Commands() { | ||
| checkCmd(sub) | ||
| } | ||
| } | ||
| checkCmd(rootCmd) | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -103,8 +103,8 @@ For detailed help on any command, use: | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| var newCmd = &cobra.Command{ | ||||||||||||||||||||||||
| Use: "new [workflow]", | ||||||||||||||||||||||||
| Short: "Create a new workflow Markdown file with example configuration", | ||||||||||||||||||||||||
| Long: `Create a new workflow Markdown file with commented examples and explanations of all available options. | ||||||||||||||||||||||||
| Short: "Create a new agentic workflow file with example configuration", | ||||||||||||||||||||||||
| Long: `Create a new agentic workflow file with commented examples and explanations of all available options. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| When called without a workflow name (or with --interactive flag), launches an interactive wizard | ||||||||||||||||||||||||
| to guide you through creating a workflow with custom settings. | ||||||||||||||||||||||||
|
|
@@ -162,7 +162,7 @@ Examples: | |||||||||||||||||||||||
| var removeCmd = &cobra.Command{ | ||||||||||||||||||||||||
| Use: "remove [pattern]", | ||||||||||||||||||||||||
| Short: "Remove agentic workflow files matching the given name prefix", | ||||||||||||||||||||||||
| Long: `Remove workflow files matching the given workflow-id pattern. | ||||||||||||||||||||||||
| Long: `Remove agentic workflow files matching the given workflow-id pattern. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| The workflow-id is the basename of the Markdown file without the .md extension. | ||||||||||||||||||||||||
| You can provide a workflow-id prefix to remove multiple workflows, or a specific workflow-id. | ||||||||||||||||||||||||
|
|
@@ -224,7 +224,7 @@ Examples: | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| var compileCmd = &cobra.Command{ | ||||||||||||||||||||||||
| Use: "compile [workflow]...", | ||||||||||||||||||||||||
| Short: "Compile workflow Markdown files (.md) into GitHub Actions workflows (.lock.yml)", | ||||||||||||||||||||||||
| Short: "Compile agentic workflow files (.md) into GitHub Actions workflows (.lock.yml)", | ||||||||||||||||||||||||
| Long: `Compile one or more agentic workflows to YAML workflows. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| If no workflows are specified, all Markdown files in .github/workflows will be compiled. | ||||||||||||||||||||||||
|
|
@@ -790,6 +790,30 @@ Use "` + string(constants.CLIExtensionPrefix) + ` help all" to show help for all | |||||||||||||||||||||||
| rootCmd.AddCommand(completionCmd) | ||||||||||||||||||||||||
| rootCmd.AddCommand(hashCmd) | ||||||||||||||||||||||||
| rootCmd.AddCommand(projectCmd) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Fix help flag descriptions for all subcommands to be consistent with the | ||||||||||||||||||||||||
| // root command ("Show help for gh aw" vs the Cobra default "help for [cmd]"). | ||||||||||||||||||||||||
| var fixSubCmdHelpFlags func(cmd *cobra.Command) | ||||||||||||||||||||||||
| fixSubCmdHelpFlags = func(cmd *cobra.Command) { | ||||||||||||||||||||||||
| cmd.InitDefaultHelpFlag() | ||||||||||||||||||||||||
| if f := cmd.Flags().Lookup("help"); f != nil { | ||||||||||||||||||||||||
| cmdPath := cmd.CommandPath() | ||||||||||||||||||||||||
| // CommandPath() uses Name() which returns the first word of Use | ||||||||||||||||||||||||
| // ("gh" from "gh aw"), so subcommand paths look like "gh compile". | ||||||||||||||||||||||||
| // Replace the leading "gh " prefix with "gh aw " to match the root | ||||||||||||||||||||||||
| // command's display name. | ||||||||||||||||||||||||
| if strings.HasPrefix(cmdPath, "gh ") && !strings.HasPrefix(cmdPath, "gh aw") { | ||||||||||||||||||||||||
| cmdPath = "gh aw " + cmdPath[3:] | ||||||||||||||||||||||||
|
Comment on lines
+803
to
+806
|
||||||||||||||||||||||||
| // Replace the leading "gh " prefix with "gh aw " to match the root | |
| // command's display name. | |
| if strings.HasPrefix(cmdPath, "gh ") && !strings.HasPrefix(cmdPath, "gh aw") { | |
| cmdPath = "gh aw " + cmdPath[3:] | |
| // Replace the leading root binary prefix (e.g. "gh ") with the full | |
| // CLI extension prefix (e.g. "gh aw ") to match the root command's | |
| // display name, derived from constants.CLIExtensionPrefix. | |
| rootName := strings.Fields(rootCmd.Use)[0] | |
| cliName := string(constants.CLIExtensionPrefix) | |
| if strings.HasPrefix(cmdPath, rootName+" ") && !strings.HasPrefix(cmdPath, cliName+" ") { | |
| cmdPath = cliName + " " + cmdPath[len(rootName)+1:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test hardcodes the expected help-flag prefix ("Show help for gh aw"). To avoid the test drifting from the CLI’s configured name, derive the expected string from constants.CLIExtensionPrefix (or reuse the same helper used to set the help flag usage).