-
-
Notifications
You must be signed in to change notification settings - Fork 241
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 only support for watson add #282
base: master
Are you sure you want to change the base?
Conversation
Looks like we finally have our first CLI tests 😉 |
Do you know why Github is displaying such a long diff for |
watson/cli.py
Outdated
|
||
def getMergedDateTime(date_time, time_string): | ||
hours, minutes = time_string.split(":") | ||
return date_time.shift(hours=int(hours), minutes=int(minutes)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those functions should probably go to the utils
module (and be unit tested ;) ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. 5729d3e
to = getMergedDateTime(from_.floor("day"), to) | ||
elif isTime(from_) and isTime(to): | ||
from_ = getDateTimeToday(from_) | ||
to = getDateTimeToday(to) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if Arrow doesn't provide something to help with that. It feels a bit tedious to introduce our own regexp to parse the date & times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have checked the api and didn't find s.th. appropriate. But I am open for suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been looking into it and there's something I don't understand: why are there two different click types Date
and Time
in cli.py
?
It turns out that both accept the full date, but using different formats!
TimeParamType
(aka,Time
) is only used inwatson stop
:
$ watson stop --at 09:00
$ watson stop --at 2019-05-23T12:00
DateParamType
(aka,Date
) is used in every other place where a date is required:
$ watson report -f 2019-05-23
$ watson report -f "2019-05-23 12:00"
$ watson report -f "2019-05-23T12:00"
In my opinion, the following changes might solve issue #278 in a simpler way:
- Rename
Date
toDateTime
which is more appropriate to what it does. Of course, rename also the correspondingParamType
classes. - Allow
DateTime
to receive time only dates, which is precisely what theTime
type does. You could reuse the code. - Use
DateTime
whereTime
was used (i.e.watson stop
). - Remove
Time
andTimeParamType
.
Please, remember that I'm not a member of this project, so I might be missing important stuff!! :-) what do you think @k4nar?
I think date/time input format is one of the aspects where Watson could get a nice improvement, so it's great that there's someone working on it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea. I didn't dive deep so I was not aware of TimeParamType which is basically doing what I implemented to handle time only.
I also couldn't agree more that the api is not consistent for the different cmds and it felt like adding another balcony.
The only drawback I see so far is that it will be hard to handle the case where we want to reuse the date specified for --from for --to as the parameter processing would be done without the knowledge about the other parameter.
Yes I am on Windows. I use checkout-as-is and commit-as-is which suits most cases very well. Have pushed a new commit fixing the line endings. |
Improve usability of watson add (issue #278)