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

Output formatting (JSON) #8

Open
nikolastojkov opened this issue Mar 23, 2021 · 7 comments
Open

Output formatting (JSON) #8

nikolastojkov opened this issue Mar 23, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@nikolastojkov
Copy link

Currently you can't specify an output format for the info returned.

It would be great if we can specify an output format for the info, e.g. JSON, XML(?), CSV etc.

Requested Usage

... --output="json"

@whoeverest
Copy link
Owner

Makes sense, having structured output is one of the goals of the tool. The tree options would probably be: json|csv|tab; the last one is more or less how the data is printed today, separated by tabs.

@whoeverest whoeverest added the enhancement New feature or request label Mar 23, 2021
@Tunas1337
Copy link

I can make a PR to add a command line flag that formats and outputs the data as JSON instead of human-readable text; however, I'm not any kind of authority which can determine what the schema for the JSON will be. If you come up with a standard (or just sorta accept what I can come up with, and improve upon it) I'll be happy to contribute.

@whoeverest
Copy link
Owner

@Tunas1337 Thanks for offering your help! I'm still unsure about the details myself...

The key to this task is to first figure out how to represent the values that get printed. Currently, we just parse the HTML and print them. But ideally, we'd like to have a more stuctured representation e.g currencies that have a number part (float) and a currency (enum?)

Once we have an in-memory representation, the rest is simple. If the global --json|csv|tab flag is passed to the CLI, before printing, whatever values need to be printed get converted in the chosen format. Currenly, tab is default, since the printed output is tab delimited.

Regarding the schema, it depends on the command that's being called. On nlbcli ID accounts you get one shape of the data, on other commands other, obviously. :))

Nothing very actionable from all I just said, just thinking out loud.

@whoeverest
Copy link
Owner

Perhaps we should do a small PR, for one command, and have a discussion there. Happy to do one, or review it if you get to it first. @Tunas1337

@Tunas1337
Copy link

Tunas1337 commented Mar 29, 2021

I've been somewhat busy with work and university, but I will definitely take a look at it throughout this week; hopefully, I'll be able to make at least a preliminary PR with JSON/CSV output for one command by the end of the week. I'm thinking nlbcli accounts ID balance because it contains a lot of the data from other commands, and thus implementing it would involve determining the format for most of the other ones.

@Tunas1337
Copy link

See PR #15.

@whoeverest
Copy link
Owner

I've been somewhat busy with work and university

No worries. :) Thanks, I'll review the RP!

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