pflag
pflag copied to clipboard
Add support for time.Time flags
This PR implements support for time.Time
flags which can be used to accept timestamps as input directly (see https://github.com/spf13/cobra/issues/742).
The implementation allows defining a list of acceptable timestamp formats which are tested in order, i.e., devs using this flag type would be responsible for ordering their formats correctly should there be an overlap.
This is exactly what I am looking for. Would it be possible to review and merge this?
Maybe also suggestion for small improvement, would it be possible to offer some reasonable standard default ordering? Like this:
var DefaultOrdering []string = []string{time.RFC3339, time.UnixDate, ...}
or this:
func getDefaultOrdering() []string {
return []string{time.RFC3339, time.UnixDate, ...}
}
I was thinking of adding a constant slice with a suggested default time format set, but opted to not include it in this PR since its easy to define such a constant in whatever code you use and more importantly I wanted to avoid any long winded discussions on what the actual order and included formats should be.
@johnSchnake tagging you (a bit late) for this PR as requested in https://github.com/spf13/cobra/issues/742
hate being that guy...but: any news on when will this be in?
Yeah sadly seems that the repo is just sitting here now anymore nothing happening :/
i tried to make some noise in the related issue on the cobra side but nothing yet
Anything needed from the community side to cross the finish line with this PR? Happy to test, review, anything... it is a bit of a shame that the de-facto standard CLI library doesn't have a time.Time
flag like it has already for time.Duration
Good to see this has been approved... Can it be merged?
Good to see this has been approved... Can it be merged?
@Kapparina i wish it was this easy :(