Skip to content

cli: poor messaging on misconfigured duration flag #163

@nnchang

Description

@nnchang

If I have a cli with a duration flag that is not required and has no default, it will always panic with the message:

panic: time: invalid duration

this happens whether or not the user provides a value on the command line. Turns out this panic arises in the default-parsing code:

func (f DurationFlag) Default() interface{} {
dur, err := f.Parse(f.DefaultStr())
if err != nil {
panic(err)

We should have better messaging to ensure developers aren't confused when the panic happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions