8000 Allow specification of start time via `start_at` by joelostblom · Pull Request #364 · jazzband/Watson · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow spec 8000 ification of start time via start_at #364

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

Merged
merged 15 commits into from
Jun 18, 2020

Conversation

joelostblom
Copy link
Contributor

A suggestion for how to implement start_at similar to the already existing stop_at. @jmaupetit

Note that there are 11 tests failing for me on the master branch, which is unchanged with the additions suggested here.

Close #75 #224 #352

@joelostblom joelostblom mentioned this pull request Apr 24, 2020
@joelostblom
Copy link
Contributor Author

@jmaupetit Just added a couple of minor updates. This is ready for review when you get a chance. Really enjoying watson so far and looking forward to contributing more if there is interest! Thanks again for making this great tool!

@jmaupetit jmaupetit requested a review from k4nar April 27, 2020 09:30
watson/watson.py Outdated
@@ -251,7 +251,12 @@ def add(self, project, from_date, to_date, tags):
frame = self.frames.add(pro 8000 ject, from_date, to_date, tags=tags)
return frame

def start(self, project, tags=None, restart=False, gap=True):
def start(self, project, tags=None, restart=False, start_at=None, gap=True):
if start_at is not None and not gap:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed now that I could use the MutuallyExclusiveOption in the click decorator instead of this if statement. The only drawback would be that I didn't see a way to specify a custom error message which might be helpful, but it would still probably be better to handle this the same as other mutually exclusive options in watson and use the decorator. Let me know what you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we should use the decorator when applicable.

Copy link
Contributor Author
@joelostblom joelostblom May 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I changed this to use the decorator in my latest commit. Note the difference that the previous solution only raised an error if --at was used together with --no-gap, while the click decorator raises and error when used together with either --gap or --no-gap (it still works with the default parameter value of gap=True, it is just not possible to use the flag directly).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also just a note that there is apparently a click addon for options groups now https://github.com/click-contrib/click-option-group, including mutual exclusiveness and grouping in the help message, might be something worth checking out in the future.

@joelostblom
Copy link
Contributor Author

@k4nar @jmaupetit I restructured my previous changes to fix the failed tests in my latest commit. The only failing test now is related to flake8 and also fails for me on master. Could you review this PR and let me know if you think the changes are sound before I try to add a test specifically for start_at?

@joelostblom
Copy link
Contributor Author

I added some suggested tests now also, ready for full review. I am not quite sure the test in test_cli.py is necessary, let me know what you think.

with pytest.raises(ValueError):
time_str = '2999-31-12T23:59'
# Task can't end in the future
with pytest.raises(WatsonError):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was previously raisin ValueError because there is no month number 31. Now it correctly raises a WatsonError if the task starts in the future.

@joelostblom
Copy link
Contributor Author

@jmaupetit @k4nar Just a reminder to review this PR when you get a chance. FWIW I have been using it locally without issues.

k4nar
k4nar previously approved these changes Jun 17, 2020
Copy link
Collaborator
@k4nar k4nar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jmaupetit
Copy link
Contributor

We'll merge this after #369 🎉

@jmaupetit
Copy link
Contributor

Also: please update the CHANGELOG to add this new feature, yay!

@joelostblom
Copy link
Contributor Author

Thanks @jmaupetit ! I added a note in the changelog and rebased on #369 so should be good to go after that PR is merged.

@jmaupetit
Copy link
Contributor

I think you are good to go for a new rebase :trollface: 🙏

@joelostblom
Copy link
Contributor Author

@jmaupetit Ready!

@jmaupetit jmaupetit merged commit 2cb871e into jazzband:master Jun 18, 2020
jmaupetit added a commit that referenced this pull request Jul 3, 2020
Added:

- Log output order can now be controlled via the `--reverse/--no-reverse` flag
  and the `reverse_log` configuration option (#369)
- Add `--at` flag to the `start` and `restart` commands (#364).
- Add `--color` and `--no-color` flags to force output to be colored or not
  respectively (#350).

Changed:

- Require latest Arrow version 0.15.6 to support ISO week dates (#380)

Fixed:

- Make after-edit-check ensure that edited time stamps are not in the future
  (#381)
@jmaupetit jmaupetit mentioned this pull request Jul 3, 2020
jmaupetit added a commit that referenced this pull request Jul 3, 2020
Added:

- Log output order can now be controlled via the `--reverse/--no-reverse` flag
  and the `reverse_log` configuration option (#369)
- Add `--at` flag to the `start` and `restart` commands (#364).
- Add `--color` and `--no-color` flags to force output to be colored or not
  respectively (#350).

Changed:

- Require latest Arrow version 0.15.6 to support ISO week dates (#380)

Fixed:

- Make after-edit-check ensure that edited time stamps are not in the future
  (#381)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an optional (relative) time to the start and stop commands
3 participants
0