Skip to content

Commit d12a89b

Browse files
authored
fix(cli): standardize --help flag descriptions and "agentic workflow" terminology (#20375)
1 parent b47b0ca commit d12a89b

4 files changed

Lines changed: 63 additions & 6 deletions

File tree

cmd/gh-aw/help_flag_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//go:build !integration
2+
3+
package main
4+
5+
import (
6+
"strings"
7+
"testing"
8+
9+
"github.com/spf13/cobra"
10+
)
11+
12+
// TestHelpFlagConsistency verifies that all commands have consistent --help flag
13+
// descriptions starting with "Show help for gh aw" (matching the root command).
14+
func TestHelpFlagConsistency(t *testing.T) {
15+
var checkCmd func(cmd *cobra.Command)
16+
checkCmd = func(cmd *cobra.Command) {
17+
t.Run("command "+cmd.CommandPath()+" has consistent help flag", func(t *testing.T) {
18+
cmd.InitDefaultHelpFlag()
19+
f := cmd.Flags().Lookup("help")
20+
if f == nil {
21+
t.Skip("Command has no help flag")
22+
}
23+
want := "Show help for gh aw"
24+
if !strings.HasPrefix(f.Usage, want) {
25+
t.Errorf("Command %q help flag Usage = %q, want prefix %q", cmd.CommandPath(), f.Usage, want)
26+
}
27+
})
28+
for _, sub := range cmd.Commands() {
29+
checkCmd(sub)
30+
}
31+
}
32+
checkCmd(rootCmd)
33+
}

cmd/gh-aw/main.go

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ For detailed help on any command, use:
103103

104104
var newCmd = &cobra.Command{
105105
Use: "new [workflow]",
106-
Short: "Create a new workflow Markdown file with example configuration",
107-
Long: `Create a new workflow Markdown file with commented examples and explanations of all available options.
106+
Short: "Create a new agentic workflow file with example configuration",
107+
Long: `Create a new agentic workflow file with commented examples and explanations of all available options.
108108
109109
When called without a workflow name (or with --interactive flag), launches an interactive wizard
110110
to guide you through creating a workflow with custom settings.
@@ -162,7 +162,7 @@ Examples:
162162
var removeCmd = &cobra.Command{
163163
Use: "remove [pattern]",
164164
Short: "Remove agentic workflow files matching the given name prefix",
165-
Long: `Remove workflow files matching the given workflow-id pattern.
165+
Long: `Remove agentic workflow files matching the given workflow-id pattern.
166166
167167
The workflow-id is the basename of the Markdown file without the .md extension.
168168
You can provide a workflow-id prefix to remove multiple workflows, or a specific workflow-id.
@@ -224,7 +224,7 @@ Examples:
224224

225225
var compileCmd = &cobra.Command{
226226
Use: "compile [workflow]...",
227-
Short: "Compile workflow Markdown files (.md) into GitHub Actions workflows (.lock.yml)",
227+
Short: "Compile agentic workflow files (.md) into GitHub Actions workflows (.lock.yml)",
228228
Long: `Compile one or more agentic workflows to YAML workflows.
229229
230230
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
790790
rootCmd.AddCommand(completionCmd)
791791
rootCmd.AddCommand(hashCmd)
792792
rootCmd.AddCommand(projectCmd)
793+
794+
// Fix help flag descriptions for all subcommands to be consistent with the
795+
// root command ("Show help for gh aw" vs the Cobra default "help for [cmd]").
796+
var fixSubCmdHelpFlags func(cmd *cobra.Command)
797+
fixSubCmdHelpFlags = func(cmd *cobra.Command) {
798+
cmd.InitDefaultHelpFlag()
799+
if f := cmd.Flags().Lookup("help"); f != nil {
800+
cmdPath := cmd.CommandPath()
801+
// CommandPath() uses Name() which returns the first word of Use
802+
// ("gh" from "gh aw"), so subcommand paths look like "gh compile".
803+
// Replace the leading "gh " prefix with "gh aw " to match the root
804+
// command's display name.
805+
if strings.HasPrefix(cmdPath, "gh ") && !strings.HasPrefix(cmdPath, "gh aw") {
806+
cmdPath = "gh aw " + cmdPath[3:]
807+
}
808+
f.Usage = "Show help for " + cmdPath
809+
}
810+
for _, sub := range cmd.Commands() {
811+
fixSubCmdHelpFlags(sub)
812+
}
813+
}
814+
for _, sub := range rootCmd.Commands() {
815+
fixSubCmdHelpFlags(sub)
816+
}
793817
}
794818

795819
func main() {

pkg/cli/add_command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func NewAddCommand(validateEngine func(string) error) *cobra.Command {
4848
cmd := &cobra.Command{
4949
Use: "add <workflow>...",
5050
Short: "Add agentic workflows from repositories to .github/workflows",
51-
Long: `Add one or more workflows from repositories to .github/workflows.
51+
Long: `Add one or more agentic workflows from repositories to .github/workflows.
5252
5353
This command adds workflows directly without interactive prompts. Use 'add-wizard'
5454
for a guided setup that configures secrets, creates a pull request, and more.

pkg/cli/fix_command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func NewFixCommand() *cobra.Command {
3333
cmd := &cobra.Command{
3434
Use: "fix [workflow]...",
3535
Short: "Apply automatic codemod-style fixes to agentic workflow files",
36-
Long: `Apply automatic codemod-style fixes to agentic workflow Markdown files.
36+
Long: `Apply automatic codemod-style fixes to agentic workflow files.
3737
3838
This command applies a registry of codemods that automatically update deprecated fields
3939
and migrate to new syntax. Codemods preserve formatting and comments as much as possible.

0 commit comments

Comments
 (0)