Add Date-related parameter types
numbsafari opened this issue · comments
I apologize if this is the wrong way to open this up, I went to the IRC channel and posted there but did not really get any response.
Many of the scripts I write have date options, e.g.:
$ my-app import-task --start-date=2015-01-01 --end-date=2016-01-01
$ my-app import-task --date=2015-01-01 --lookback=3days
$ my-app import-task --lookback=1week
- Explicit dates/times.
timedelta
s- Defaults settable to
now
/utcnow
I think this would be pretty trivial to add, focused strictly on the built-in datetime
package. One could take advantage of other date parsing utility libraries, but that would add dependencies that might not be needed by others.
I'm willing to make a PR for this, just wanted to get a bit of feedback or a nod before submitting something from left field. Also, if you think simple "DateType" support would be better as a click-contrib
package, and I'll go that route.
I agree that this is a common use case. I am also willing to contribute, and am curious if the correct route is to submit a PR or create a click-contrib package.
I have created a repo called click-datetime
and have started working on supporting Datetime objects. @numbsafari I sent you an invite as a contributor to the repo.
I think a better path for now would be click-contrib. I can invite either of you as member such that you can create your own repos there (and transfer existing ones).
@untitaker sounds good. I have created https://github.com/ddaws/click-datetime and will migrate to click-contrib when added.
Done
@untitaker should this issue be closed because this functionality is now available via a contrib package?
Yes, thanks for the reminder.
@ddaws - thanks for contributing click-datetime
, was looking for exactly this (and I kinda expected it to be in Click core, but hey, dates / times can get complicated, so maybe it's better in a separate project), will give it a try now.