Skip to content

Commit 2ecd6b1

Browse files
authored
feat(cli): add advanced command hint to help output (#102)
Adds a hint to the bottom of `azldev` usage info, pointing at `azldev advanced`.
1 parent 710de7a commit 2ecd6b1

8 files changed

+20
-0
lines changed

internal/app/azldev/app.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ lives), or use -C to point to one.`,
155155

156156
app.cmd.SetHelpCommandGroupID(CommandGroupMeta)
157157
app.cmd.SetCompletionCommandGroupID(CommandGroupMeta)
158+
app.addAdvancedCommandHint()
158159

159160
// Define global flags and configuration settings.
160161
app.cmd.PersistentFlags().BoolVarP(&app.verbose, "verbose", "v", false, "enable verbose output")
@@ -179,6 +180,18 @@ lives), or use -C to point to one.`,
179180
return app
180181
}
181182

183+
// addAdvancedCommandHint embeds a hint about the hidden "advanced" command group
184+
// into the root command's usage template so that DisableExtraNewlines handles
185+
// trailing whitespace consistently.
186+
func (a *App) addAdvancedCommandHint() {
187+
tmpl := a.cmd.UsageTemplate()
188+
tmpl = strings.TrimSuffix(tmpl, "\n")
189+
tmpl += `{{if not .HasParent}}
190+
Use "{{.CommandPath}} advanced --help" for additional tools (mock, mcp, wget).{{end}}
191+
`
192+
a.cmd.SetUsageTemplate(tmpl)
193+
}
194+
182195
// Returns the names of the app's commands. The optional provided list of ancestors
183196
// instructs this function to traverse through the command hierarchy before retrieving
184197
// child names. This function is largely intended for tests to introspect on the

scenario/__snapshots__/TestSnapshotsContainer_--bogus-flag_stderr_1.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Flags:
3131
--version version for azldev
3232

3333
Use "azldev [command] --help" for more information about a command.
34+
Use "azldev advanced --help" for additional tools (mock, mcp, wget).
3435

3536

3637
##:##:## ERR Error: unknown flag: --bogus-flag

scenario/__snapshots__/TestSnapshotsContainer_--help_stdout_1.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ Flags:
3838
--version version for azldev
3939

4040
Use "azldev [command] --help" for more information about a command.
41+
Use "azldev advanced --help" for additional tools (mock, mcp, wget).
4142

scenario/__snapshots__/TestSnapshotsContainer_help_stdout_1.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ Flags:
3838
--version version for azldev
3939

4040
Use "azldev [command] --help" for more information about a command.
41+
Use "azldev advanced --help" for additional tools (mock, mcp, wget).
4142

scenario/__snapshots__/TestSnapshots_--bogus-flag_stderr_1.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Flags:
3131
--version version for azldev
3232

3333
Use "azldev [command] --help" for more information about a command.
34+
Use "azldev advanced --help" for additional tools (mock, mcp, wget).
3435

3536

3637
##:##:## ERR Error: unknown flag: --bogus-flag

scenario/__snapshots__/TestSnapshots_--help_stdout_1.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ Flags:
3838
--version version for azldev
3939

4040
Use "azldev [command] --help" for more information about a command.
41+
Use "azldev advanced --help" for additional tools (mock, mcp, wget).
4142

scenario/__snapshots__/TestSnapshots_--help_with_color_stdout_1.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ Meta commands:
3838
--version version for azldev
3939

4040
Use "azldev [command] --help" for more information about a command.
41+
Use "azldev advanced --help" for additional tools (mock, mcp, wget).
4142

scenario/__snapshots__/TestSnapshots_help_stdout_1.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ Flags:
3838
--version version for azldev
3939

4040
Use "azldev [command] --help" for more information about a command.
41+
Use "azldev advanced --help" for additional tools (mock, mcp, wget).
4142

0 commit comments

Comments
 (0)