Skip to content

Commit

Permalink
- Fixing issue with nil default values.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristoffer Ahl committed Apr 4, 2020
1 parent 291a2ad commit 0b3f59c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions cmd/centry/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,37 @@ func toCliFlags(options *cmd.OptionsSet) []cli.Flag {

switch o.Type {
case cmd.SelectOption:
def := false
if o.Default != nil {
def = o.Default.(bool)
}
flags = append(flags, &cli.BoolFlag{
Name: o.Name,
Aliases: short,
Usage: o.Description,
Value: o.Default.(bool),
Value: def,
})
case cmd.BoolOption:
def := false
if o.Default != nil {
def = o.Default.(bool)
}
flags = append(flags, &cli.BoolFlag{
Name: o.Name,
Aliases: short,
Usage: o.Description,
Value: o.Default.(bool),
Value: def,
})
case cmd.StringOption:
def := ""
if o.Default != nil {
def = o.Default.(string)
}
flags = append(flags, &cli.StringFlag{
Name: o.Name,
Aliases: short,
Usage: o.Description,
Value: o.Default.(string),
Value: def,
})
}
}
Expand Down

0 comments on commit 0b3f59c

Please sign in to comment.