-
Notifications
You must be signed in to change notification settings - Fork 2
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 json output to test CLI command output #1164
Conversation
Since this is a breaking change it is paired with a PR in programs to update the CLI for deploying programs, which has |
program_info.bytecode.len(), | ||
!program_info.configuration_schema.is_empty(), | ||
!program_info.auxiliary_data_schema.is_empty(), | ||
"{:<64} {:<48} {:<11} {:<14} {} {}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this PR but needed tidying
@@ -186,15 +191,22 @@ enum CliCommand { | |||
}, | |||
} | |||
|
|||
impl Cli { | |||
fn log(&self, text: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious why this was needed and not just a println macro?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah its a wierd way of doing it. just so it only logs when the json option is false, to prevent the log lines being parsed as json.
This looks good to me, thank you! |
Closes #1163
This adds optional JSON output to the test CLI.
This is activated with the
--json
or-j
command line argument. Note that it must be given before the subcommand like this:entropy-test-cli --json status
and notentropy-test-cli status --json
.Currently not all available information is given, for example the status command gives you the hashes of stored programs and account ids of registered accounts, but not the additional metadata you will see in the non-json output, such as which programs are associated with which account, who stored a program, how many times a program was used, etc. These fields could easily be added so please say if they would be useful.
Generally binary data is represented as hex.
Example output:
For commands which finish successfully with no output, an empty JSON object is displayed:
{}
. Im not sure if it would be more appropriate to just give no ouput.Errors
Errors are currently not displayed as JSON. If a command fails, the exit status will be
1
, and the original error message will be displayed to standard error. If needed we could wrap this in{ "error": "error message" }
, but actually serializing the errors to JSON is probably going to be tricky as i imagine they will not all implementSerialize
.