-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Support JSON output in report command #102
Conversation
80ab323
to
9a2ebe4
Compare
Thank you @timofurrer ! JSON output seems a relevant feature. Can you share a concrete use case with us? I mean to which program do you pipe this output to? Side question: did you update |
I don't have a specific tool at the moment. However, I plan to write an adapter for some company specific time tracking tools ;) .. and beside that I thought others might have the same idea so I just implemented it . Yeah, I documented it -> See changeset. Is something wrong about it? |
I am glad that you prefer using Watson than the time tracker of your company ❤️
Yep, saw it. That is why I asked. Nothing wrong, just noise. |
docs/user-guide/commands.md
Outdated
@@ -341,6 +366,7 @@ Flag | Help | |||
`-t, --to DATE` | The date at which the report should stop (inclusive). Defaults to tomorrow. | |||
`-p, --project TEXT` | Reports activity only for the given project. You can add other projects by using this option several times. | |||
`-T, --tag TEXT` | Reports activity only for frames containing the given tag. You can add several tags by using this option multiple times | |||
`-j, --json` | Outputs the report as JSON instead of writing to the console |
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.
JSON output still goes to the console, doesn't it? Just the format changes from formatted text with escape sequences to JSON. How can this be reworded to be more accurate?
@timofurrer Do you still plan to update this PR according to the feedback? |
Completely forgot about this PR. I'll have a look at it asap. |
docs/user-guide/commands.md
Outdated
apollo11 - 13h 22m 20s | ||
[brakes 7h 53m 18s] | ||
[module 7h 41m 41s] | ||
[reactor 8h 35m 50s] | ||
[steering 10h 33m 37s] | ||
[wheels 10h 11m 35s] | ||
|
||
$ watson report --format json |
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.
Here you document --format json
while the actual option is --json
.
BTW, I think the --format
is better since it leaves room to future other formats without adding lots of distinct options.
9a2ebe4
to
f1dce0f
Compare
f1dce0f
to
6512130
Compare
It's definitely been a while - I apologize for that! I've updated the PR and reworded the option description. We could also enhance the current implementation with the |
Umm, not sure, how about |
I would keep |
Well, the json output is
What about a shortcut to I can do either one. Who makes the call? |
Thanks for the update @timofurrer ! I would also keep the |
e3e1fdf
to
f648349
Compare
@jmaupetit @willdurand I've updated the PR according to your suggestion to use |
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.
Thank you for this contribution! Can you please use double quotes for translatable strings only? I have mentioned this point in your tests, but I see that there are a few left in your code.
tests/test_watson.py
Outdated
assert len(report["projects"]) == 1 | ||
assert report["projects"][0]["name"] == "foo" | ||
assert len(report["projects"][0]["tags"]) == 1 | ||
assert report["projects"][0]["tags"][0]["name"] == "B" |
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.
Can you please use single quotes for non-translatable strings?
watson/cli.py
Outdated
@@ -325,8 +325,11 @@ def status(watson): | |||
help="Reports activity only for frames containing the given " | |||
"tag. You can add several tags by using this option multiple " | |||
"times") | |||
@click.option('-j', '--json', 'format_json', is_flag=True, | |||
help='Format the report in JSON instead of plaintext') |
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.
s/plaintext/plain text/
watson/cli.py
Outdated
@@ -346,6 +349,9 @@ def report(watson, current, from_, to, projects, tags, year, month, week, day): | |||
`--tag` options. They can be specified several times each to add multiple | |||
projects or tags to the report. | |||
|
|||
You can change the output format for the report from *plaintext* to *JSON* |
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.
Idem: s/plaintext/plain text/
ca5941c
to
2505db8
Compare
@jmaupetit okay. I'm not quiet sure what you mean with translatable strings - I couldn't find a consistent pattern for the use of But I guessed and pushed - Have a look at it 🍻 |
Thank you for these changes. I am sorry to insist, but there are some double quotes left in |
2505db8
to
66a3782
Compare
Done. I think some clear guide lines would really help people to contribute more efficiently ... ;) |
I do agree with you, especially here since I do not know what translatable strings are either. Maybe @jmaupetit could give an explanation here, and we will update the |
@timofurrer I am sorry if you felt frustrated after submitting code to this PR. This coding convention is implicit, but required to maintain consistency over the project. We need to work on this. To briefly explain it, translatable strings are literal strings containing natural language messages that may be translated during the internationalization of the app. All other strings acting as "identifiers" are single quoted (dictionary keys, etc.) |
Use
--json
switch to change report output from console output to JSON.