-
Notifications
You must be signed in to change notification settings - Fork 250
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
Feat/current alternative formating #616
base: master
Are you sure you want to change the base?
Feat/current alternative formating #616
Conversation
e665e3f
to
13b3a7a
Compare
Thanks for the PR. Unfortunately I have to say I'm not convinced. We have the "export" functionality for choosing different output formats. It would be straightforward to add JSON as a new export format. Pushing it into the main CLI, as here, would make JSON special compared to CSV and XML. I see no reason for doing that. It makes little sense from the user perspective, either. If the user wants XML output, she needs to run " Moreover, putting this functionality into hamster-cli prevents json from being used in other contexts. JSON format would probably good-to-have in the GUI too, and perhaps even for foreign clients like the GNOME extension. I am no friend of changes that favor one UI over the other. This said, a JSON export format would be highly welcome. And feel invited to convince me that I'm wrong and that the way you implemented this was exactly what we need. |
I haven't looked at the code yet, but I would agree that extending the current export command would be favorable over adding a new command (at least from a UI POV).
How would you see this working? The GUI does not currently have any CSV or XML features either, right? And the DBus API actually already supports JSON format for facts: hamster/src/hamster-service.py Line 319 in 21facca
Re-reading the original PR description, I believe the intent is to add JSON formatting as a machine-readable for various command, so not just for export. IOW, adding a JSON export format would not solve the entire problem that (I think) this PR is trying to solve. So maybe both of these could co-exist: having a json export format, and allowing |
@mwilck my intention was to add JSON/XML/TSV or any other programatic output format to small CLI commands like Currently the output format is flagged only for export command, other commands do not have any way of changing format. |
So trying to guess your expectations, I have two options to get JSON output from
What's your proposed solution to do that ? |
It has the export functionality, that's it. I haven't thought this through. The reasoning was more like "if we implement this for CLI only today, we may notice some time later that it could come in handy elsewhere, too".
|
This is because "-1" means "1 minute ago" to hamster. I have to admit this doesn't always work; if the current activity started less than 1 minute ago, it may print the previous activity, too. I understand your idea now better. I'm not against a generic --format switch, but I'd like to see the core code shared between the CLI output and the export functionality. IOW, implement "export json" first, and make the code reusable for your CLI needs. The most generic solution would leverage all the existing export formatters, and allow to use any of them for CLI output. Next, talking about JOSN, as @matthijskooijman already hinted at, users might expect JSON input to work, too 😁 ... but let's focus on output first. |
5c25c3c
to
34d3a72
Compare
@mwilck Thanks for constructive feedback, now I think we can get to something. Please see MR commits now , I'm using I've added Implementation of |
@mwilck @matthijskooijman is there anything I can do to help you with that MR further ? |
Sorry I had no time for hamster lately... so this is on top of #617? |
Use `reports` module that provide multiple output formats to format output of `current` action.
34d3a72
to
5b8a091
Compare
I wanted to provide JSON output for simple CLI commands, like
current
,activities
orcategories
.In attached MR you can see my proposition of implementation using MVC approach.