Skip to content

Improve implementation for JSON and raw options#309

Merged
6 commits merged intodevelopfrom
unknown repository
Mar 3, 2023
Merged

Improve implementation for JSON and raw options#309
6 commits merged intodevelopfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Feb 27, 2023

Purpose

Continue the work to align the Zonemaster-CLI implementation with its own documentation.

Context

Follow-up on #308
#247 (comment)

Changes

  • Make --json-stream entail --json
  • Deprecate --[no-]json-translate, use --[no-]raw instead
  • Refactor CLI.pm

How to test this PR

Test several configurations mixing --json, --raw, --json-stream.

zonemaster-cli --json-stream --raw zonemaster.net
zonemaster-cli --json-stream zonemaster.net
zonemaster-cli --json zonemaster.net
zonemaster-cli --json --raw zonemaster.net
zonemaster-cli --json --json-stream --raw zonemaster.net

@ghost ghost added the V-Major Versioning: The change gives an update of major in version. label Feb 27, 2023
@ghost ghost added this to the v2023.1 milestone Feb 27, 2023
@ghost ghost changed the title Json raw Improve implementation for JSON and raw options Feb 27, 2023
@marc-vanderwal
Copy link
Contributor

A big improvement, definitely, which reduces the combinations of command-line options that do nothing (e.g. --no-json-translate without having given either --json or --json-stream).

With this design, all combinations make sense, except for one: --json-stream --no-json. Currently, it does the same thing as either --json-stream alone or --json-stream --json. I think zonemaster-cli should error out instead.

Because --[no-]json-translate is going to be deprecated, it may be a good thing to warn the user, and tell them the new set of options to use. For example:

  • if --no-json-translate is given, tell them they should pass --raw instead;
  • if --json-translate is given, tell them they should pass --no-raw instead;
  • additionally, if --no-json-translate or --json-translate is given without either --json or --json-stream, tell the user that the option has no effect without either of those two.

@ghost
Copy link
Author

ghost commented Feb 28, 2023

Thanks for the review and comments. I've updated the PR to display error and/or warning messages to the user.

Alexandre Pion added 6 commits March 2, 2023 15:25
* remove comment for ending blocks
* clarify translation condition
The --json-translate option translates the message tag. This is similar
to the already documented --no-raw option. Therefore use --[no-]raw
instead of --[no-]json-translate
@ghost
Copy link
Author

ghost commented Mar 2, 2023

Rebased to fix conflicts and incorporate latest release changes. Please re-review.

Copy link
Contributor

@marc-vanderwal marc-vanderwal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@ghost ghost merged commit 1565fec into zonemaster:develop Mar 3, 2023
@ghost ghost deleted the json-raw branch March 13, 2023 14:22
@tgreenx
Copy link
Contributor

tgreenx commented May 31, 2023

v2023.1 Release testing

Basic testing:

  • Make --json-stream entail --json. --> OK
  • Deprecate --[no-]json-translate, use --[no-]raw instead. --> OK

Bugs:

Observations:

  • --json --no-raw (or just --json) includes the content of --raw (message tag and args). --> Acceptable but undocumented behavior.

@tgreenx tgreenx added the S-ReleaseTested Status: The PR has been successfully tested in release testing label May 31, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-ReleaseTested Status: The PR has been successfully tested in release testing V-Major Versioning: The change gives an update of major in version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants