Skip to content

Commit

Permalink
Make the "help" extension flag work with no arguments too.
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Mar 7, 2024
1 parent 311f257 commit ee4e5b0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
// The caller is free to edit the resulting command, each call returns a
// separate value.
//
// As a special case, if there are multiple arguments after the help command
// and the first is one of "-a", "-all", or "--all", that argument is discarded
// and the rendered help text includes unlisted commands and private flags.
// As a special case, if there are arguments after the help command and the
// first is one of "-a", "-all", or "--all", that argument is discarded and the
// rendered help text includes unlisted commands and private flags.
func HelpCommand(topics []HelpTopic) *C {
cmd := &C{
Name: "help",
Expand All @@ -28,7 +28,7 @@ func HelpCommand(topics []HelpTopic) *C {
CustomFlags: true,

Run: func(env *Env) error {
if len(env.Args) >= 2 { // maybe: help -a foo
if len(env.Args) >= 1 { // maybe: help -a foo
switch env.Args[0] {
case "-a", "-all", "--all":
env.HelpFlags(IncludeUnlisted | IncludePrivateFlags)
Expand Down

0 comments on commit ee4e5b0

Please sign in to comment.