-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
time.Time flags #742
Comments
This issue is being marked as stale due to a long period of inactivity |
Seems like there was positive feedback on this issue and it would be relatively straight forward to support a new flag type. This would go into https://github.com/spf13/pflag though. I'd be happy to review a PR for that if you tag me. I think that you just need to provide the ability to define the flag and the format string you expect. |
This PR implements support for `time.Time` flags which can be used to accept timestamps as input directly (see spf13/cobra#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. Merge spf13#348
Hi there... |
@donacarr spf13/pflag#348 has been ready to be merged for a while now, but still waiting for review. CC: @johnSchnake |
I think this would be an awesome addition to this fantastic library, any chance we can get a review here?: |
Hi,
Is there simple way to handle time flags? For example, I use the following flags in my cli:
I have not found according functions in go doc, and use the following workaround: I save start/end values using
StringVarP
and then define layout and parse strings withtime.Parse
.Does cobra provide functions for handling time flags?
The text was updated successfully, but these errors were encountered: