-
Notifications
You must be signed in to change notification settings - Fork 54
Add a flag to output data in JSON #45
Comments
Good idea. I'm using more and more JSON output myself, so I can understand the usecase. Will see how easy it is to add JSON. Thanks for the feedback! |
I added https://github.com/MoriTanosuke/glacieruploader/blob/master/src/main/java/de/kopis/glacier/printers/VaultPrinter.java pretty early, but it's hardcoded in a lot of places and probably not fit for the task. At the moment the Commands do not output anything, just logging. Also there is no return value, so probably the |
I've got a working prototype that works but i'm not a big fan of having to have the printer have a switch for raw/json. I also had to make it output an array of JSON objects instead so I used a single instance of the printer and buffered the output until it's flushed. The auto-flush is ensure using the try-with-resource block which works nicely. I'm thinking of keeping the printers but trying to have different classes and have something along the lines:
It might be over-engineering the thing :-) |
I'll put theses changes up tomorrow night (PST time). |
Nice, that would be a great starting point. 👍 |
What comes to mind first is a modification on the interface for
Then all commands can return a
There should still be something like a
That way the I'll give it a go and see how far I come. @Megra Does this sound like what you had in mind in any case ❓ |
This is meant as a way to have commands return an exit status and probably display it as JSON. See #45
Ok, I pushed my local branch. See https://github.com/MoriTanosuke/glacieruploader/tree/optional-command-responses for my changes so far and let me know what you think. I'll leave the branch open until this issue is solved. |
I pushed a small change to the branch and https://github.com/MoriTanosuke/glacieruploader/blob/optional-command-responses/src/main/java/de/kopis/glacier/GlacierUploader.java#L119 now takes the This is what I got for an invalid command:
The first 3 lines are from my logging configuration. The last line prints the result as a JSON String. If there is a more information from the Amazon classes available, there would also be a field originalMessage with more information. I also added the request ID in its own field in the JSON for easier access. Should be useful if a script has to remember or report those errors. |
It would be nice to have a way to output the data in JSON to make it machine-parsable.
The use case here is to have a script that operates at a high-level while glacieruploader handles all of the operations/credentials.
Part of the changes that seems to be done include:
The text was updated successfully, but these errors were encountered: