Cli: TimeFlag

Created on 29 Dec 2017  路  5Comments  路  Source: urfave/cli

I'd like to add a cli.TimeFlag. Is this something that would be accepted as a pull request?

Also, I would like to be able to specify the format of the time in the flag.

cli.TimeFlag{
    Name:  "date",
    Usage: "date",
    Format: "2016-01-02",
}

However, I can't specify an extra field flag-types.json. Should I create custom flag type in flag.go or should I add the possibility of adding extra fields in generate-flag-types?

kinfeature statuconfirmed

All 5 comments

Hi @LeonB,

I'd welcome the addition of a TimeFlag with a format specifier. I think we could modify the schema in flag-types.json to allow the specification of additional struct fields. To make it agnostic, we could just do something like:

    {
      "name": "TimeFlag",
      "type": "time.Time",
      "context_default": "nil",
      "extra_fields": {
           "Format": "string",
       },
    }

What do you think?

Curious if you have any thoughts on that @meatballhat

@jszwedko I agree with you! :sparkling_heart:

Would also welcome this feature!

I don't know if the timeflag can be added because of the dependency on flag.FlagSet which doesn't support time flags.

Given that this is from last year, I think I'm comfortable closing it 馃檪 feel free to re-open / open a new issue / comment in support if there's still interest here!

Was this page helpful?
0 / 5 - 0 ratings