-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Make JSON output more consistent across commands #547
Comments
And actually, the behavior that would be most preferable in my humble opinion, is to not actually return a message at all, just a boolean indicating whether the operation was successful or not. |
First of all, thanks for your detailed explanation.
I only had few feedback about the JSON feature (which I barely use myself), so I would be glad to have one from a potential real user of that feature. This issue is definitely related to #539. I am currently not satisfied with the way Himalaya CLI manages output. To summarize (including your feedback):
The initial idea I had was to:
To complete with what you proposed, when
I'm afraid it would conflict with the exit status, which is IMHO way enough to determine if sth went wrong or not. The boolean can be easily simulated with Regarding For all the rest I agree. The first thing would be to tackle this |
Hello! Sorry for not answering sooner.
Yes, and anything else intended for humans can still go to stderr
Yes, that's a sensible approach, the boolean can be the exit code, and the json can contain the reason.
Me neither, all options are fine, my only opinion on the subject would be to try to keep things simple.
Agree As far as I'm concerned, this issue no longer affects my own use of himalaya, feel free to keep it around or close it as you see fit without asking. |
Let's keep the issue for a more consistent JSON output. Tightly related to #539. |
I extend the scope of this task to all commands. JSON output should be consistent across all commands. |
Context
I don't know for other users but my main usage of himalaya will be programmatic: I'm going to integrate himalaya with Python or Powershell scripts to handle daily email sifting and sorting and perhaps sometimes answer drafting (AI tools like ollama come to mind).
Long story short, I will almost exclusively use the JSON output and only use the nice tables for testing and debugging purposes.
Possibility for improvement
Currently, himalaya does not really return JSON upon imperative operations such as folder creation or deletion, or rather, it serializes to JSON the message that would have been printed to the user. At least that's what it does upon success.
It would, in my humble opinion, be nicer if it returned a boolean assorted to a message (or even just a boolean).
On failure however, himalaya does not return JSON, it simply errors out, which is not very nice for pipelining purposes.
The boolean assorted with a message would be quite preferable.
As a side note, currently creating a folder twice first yields a success then an error. Maybe yielding two successes "The folder has been created" then "The folder already exists" might be better.
Going further in that line of thought: currently
add
is an alias forcreate
. I've recently gone through the pain of configuring a Linux firewall with netfilter, and it turns out it has interesting semantics forcreate
andadd
. Maybe adopting that semantic would be unnecessarily fancy, but in netfilter,add
andcreate
do the same thing when the firewall/rule does not exist, but when it already exists,add
does not yield an error (because after all the table/rule already exists), andcreate
yields an error because the table/rule could not be created.As a side side note, the tone of the messages in JSON might be slightly less enthusiastic than the console output and drop the exclamation mark at the end ¯\(ツ)/¯
Examples
Folder creation
Current behavior:
Preferred behavior:
Folder creation when the folder already exists
Current behavior:
Preferred behavior:
If the same semantics as netfilter's
add
andcreate
are to be adoptedadd
create
I'd actually argue against implementing netfilter's behavior for simplicity's sake
Just having a "true" because the folder is already there, regardless of whether
add
orcreate
was used, would be mighty fine, in my humble opinion.Folder deletion
Current behavior:
Preferred behavior:
Folder deletion when the folder does not exist
Preferred behavior:
Addendum
I've yet to discover and use all of himalaya's features, but this opinion on JSON output is probably transferable to other functionalities too, not just folder creation/deletion.
The text was updated successfully, but these errors were encountered: