Skip to content
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

Add option to parse output to json #18

Open
georg90 opened this issue Oct 25, 2020 · 7 comments
Open

Add option to parse output to json #18

georg90 opened this issue Oct 25, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@georg90
Copy link

georg90 commented Oct 25, 2020

As title says, would make it easier to reuse the result in any script / api.

Thanks for the awesome tool @Pectojin !

@georg90
Copy link
Author

georg90 commented Oct 29, 2020

Also dynamic date values / time values (such as Start = 12:00 AM vs. Start = 22/10/2020) could be addressed, so the input is always in the same format

@Pectojin
Copy link
Owner

The current log_ouput function does not care what data is output and it doesn't care whether the program exits immediately after or if it will log more output later. This makes it somewhat tricky to output one valid json object.

We're probably talking an overhaul for how all functions return data and how they log helpful messages.

@Pectojin Pectojin added the enhancement New feature or request label Oct 30, 2020
@georg90
Copy link
Author

georg90 commented Nov 1, 2020

@Pectojin So you're saying it just outputs what it gets as soon as it gets it? This would make it hard to parse one json obj.

Is the conversion of timestamps e.g. if backup was done today it displays 12:00 AM instead of 01/11/2020 done by duplicati-client or duplicate itself?

@Pectojin
Copy link
Owner

Pectojin commented Dec 2, 2020

A lot of the timestamps are internally converted to the short form. I have an internal parameter to use the precise format instead, but that isn't available to the user.

I've gone ahead and added a config option for using precise time.

# duc precise enable
precise mode: True
# duc status        
Server       : http://localhost:8200
Server state : Running
Server status: Idle
Logged in    : 12:28:21 AM 02/12/2020
Expiration   : 12:45:38 AM 02/12/2020

The relevant changes are here: 5dbd54f

I'll update the release when I get a chance one of the coming days.

I'm keeping the issue open to track the JSON output enhancement. I'm not entirely sure how to accomplish that, but maybe it'll come to me at some point.

@avmaksimov
Copy link
Contributor

I added --output=json to commands that writes YAML and now they can write in json.

But other commands return only texts as before.

@Pectojin
Copy link
Owner

Pectojin commented Apr 3, 2021

I've released 0.6.3 with @avmaksimov's changes so now it's possible to get json output on a lot of the commands. https://github.com/Pectojin/duplicati-client/releases/tag/0.6.3_beta

Still missing some places, so keeping the issue open as an area for enhancement.

@avmaksimov
Copy link
Contributor

I've released 0.6.3 with @avmaksimov's changes so now it's possible to get json output on a lot of the commands. https://github.com/Pectojin/duplicati-client/releases/tag/0.6.3_beta

Still missing some places, so keeping the issue open as an area for enhancement.

What do you mean about a lot of commands? Because I added to places where was output to yaml. But many commands have only text output, for example: login. So do you wanna add json or yaml to all commands?
I think it's too hard to implement but also hard to use it after modification.

And about date-time command I think that easier to convert from another script that add date-time format to this simple, but useful program (I see it as script automatization helper).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants