Skip to content

Commit

Permalink
refactor: version flag for global only
Browse files Browse the repository at this point in the history
  • Loading branch information
joseluisq committed Nov 30, 2020
1 parent 3231316 commit 710aa27
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app_printing.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,21 @@ func printHelp(app *App, cmd *Cmd) error {
flags = append(flags, FlagString{
Name: "help", Aliases: []string{"h"}, Summary: "Prints help information",
})
flags = append(flags, FlagString{
Name: "version", Aliases: []string{"v"}, Summary: "Prints version information",
})
if cmd == nil {
flags = append(flags, FlagString{
Name: "version", Aliases: []string{"v"}, Summary: "Prints version information",
})
}

// Calculate app or command flags positions
for _, fl := range flags {
var vFlag flagStruct
fname := ""

fname := ""
switch f := fl.(type) {
case FlagBool:
fname = f.Name
vFlag = flagStruct{
name: f.Name, aliases: f.Aliases, summary: f.Summary, defaults: f.zflag.String(), envVar: f.EnvVar}
vFlag = flagStruct{name: f.Name, aliases: f.Aliases, summary: f.Summary, defaults: f.zflag.String(), envVar: f.EnvVar}
case FlagInt:
fname = f.Name
vFlag = flagStruct{name: f.Name, aliases: f.Aliases, summary: f.Summary, defaults: f.zflag.String(), envVar: f.EnvVar}
Expand Down

0 comments on commit 710aa27

Please sign in to comment.