Skip to content

Commit

Permalink
Rename canCli to showInHelp
Browse files Browse the repository at this point in the history
  • Loading branch information
jessevdk committed Sep 23, 2018
1 parent 14b8957 commit d761e61
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ func (c *Command) match(name string) bool {
return false
}

func (c *Command) hasCliOptions() bool {
func (c *Command) hasHelpOptions() bool {
ret := false

c.eachGroup(func(g *Group) {
Expand All @@ -447,7 +447,7 @@ func (c *Command) hasCliOptions() bool {
}

for _, opt := range g.options {
if opt.canCli() {
if opt.showInHelp() {
ret = true
}
}
Expand Down
6 changes: 3 additions & 3 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (p *Parser) getAlignmentInfo() alignmentInfo {
}

for _, info := range grp.options {
if !info.canCli() {
if !info.showInHelp() {
continue
}

Expand Down Expand Up @@ -305,7 +305,7 @@ func (p *Parser) WriteHelp(writer io.Writer) {
}
} else if us, ok := allcmd.data.(Usage); ok {
usage = us.Usage()
} else if allcmd.hasCliOptions() {
} else if allcmd.hasHelpOptions() {
usage = fmt.Sprintf("[%s-OPTIONS]", allcmd.Name)
}

Expand Down Expand Up @@ -393,7 +393,7 @@ func (p *Parser) WriteHelp(writer io.Writer) {
}

for _, info := range grp.options {
if !info.canCli() {
if !info.showInHelp() {
continue
}

Expand Down
6 changes: 3 additions & 3 deletions man.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func writeManPageOptions(wr io.Writer, grp *Group) {
}

for _, opt := range group.options {
if !opt.canCli() {
if !opt.showInHelp() {
continue
}

Expand Down Expand Up @@ -148,12 +148,12 @@ func writeManPageCommand(wr io.Writer, name string, root *Command, command *Comm
var usage string
if us, ok := command.data.(Usage); ok {
usage = us.Usage()
} else if command.hasCliOptions() {
} else if command.hasHelpOptions() {
usage = fmt.Sprintf("[%s-OPTIONS]", command.Name)
}

var pre string
if root.hasCliOptions() {
if root.hasHelpOptions() {
pre = fmt.Sprintf("%s [OPTIONS] %s", root.Name, command.Name)
} else {
pre = fmt.Sprintf("%s %s", root.Name, command.Name)
Expand Down
2 changes: 1 addition & 1 deletion option.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (option *Option) set(value *string) error {
return convert("", option.value, option.tag)
}

func (option *Option) canCli() bool {
func (option *Option) showInHelp() bool {
return !option.Hidden && (option.ShortName != 0 || len(option.LongName) != 0)
}

Expand Down

0 comments on commit d761e61

Please sign in to comment.