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

governance vote view: use --output-format, like other commands, instead of --yaml #521

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

smelc
Copy link
Contributor

@smelc smelc commented Dec 13, 2023

Note

I will squash before merging but wanted to keep the commits separate in case there are comments, to better control history for myself

Changelog

- description: |
    governance vote view: use `--output-format`, like other commands, instead of `--yaml`
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
  - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  # - improvement    # QoL changes e.g. refactoring
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

Fixes #516

On the way, I shared some code in the parsers; because code duplication is what brought this issue in the first place I think.

How to trust this PR

Inspect the diff in golden files

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@smelc smelc marked this pull request as ready for review December 13, 2023 14:34
[ Opt.long "output-format"
, Opt.metavar "STRING"
, Opt.help $ mconcat
[ "Optional transaction view output format. Accepted output formats are \"json\" "
[ "Optional " <> kind <> " view output format. Accepted output formats are \"json\" "
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use a comma instead of <>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah true that, because of the leading mconcat. Good catch 👍

Change done

s <- Opt.str @String
case s of
"json" -> pure ViewOutputFormatJson
"yaml" -> pure ViewOutputFormatYaml
_ ->
fail $ mconcat
[ "Invalid transaction view output format: " <> show s
[ "Invalid " <> kind <> " output format: " <> show s
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, you can use a comma.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change done 👍

@@ -1,11 +1,13 @@
Usage: cardano-cli conway governance vote view [--yaml]
Usage: cardano-cli conway governance vote view [--output-format STRING]
Copy link
Contributor

@Jimbo4350 Jimbo4350 Dec 13, 2023

Choose a reason for hiding this comment

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

A flag here would be nicer imo: --yaml | --json. We can add flags if we ever want to include more format options. What does the parsing error look like for --output-format STRING vs specifying a misspelled flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I will do that in a follow-up PR rn, because it's a bigger change, because it affects multiple commands.

s <- Opt.str @String
case s of
"json" -> pure GovernanceActionViewOutputFormatJson
"yaml" -> pure GovernanceActionViewOutputFormatYaml
"json" -> pure ViewOutputFormatJson
Copy link
Contributor

@Jimbo4350 Jimbo4350 Dec 13, 2023

Choose a reason for hiding this comment

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

If we use flags, we can avoid _ completely

@smelc smelc force-pushed the smelc/fix-vote-view-output-format branch from cde6c71 to 23d330e Compare December 14, 2023 09:35
@smelc smelc enabled auto-merge December 14, 2023 09:37
@smelc smelc added this pull request to the merge queue Dec 14, 2023
Merged via the queue into main with commit e20d931 Dec 14, 2023
19 checks passed
@smelc smelc deleted the smelc/fix-vote-view-output-format branch December 14, 2023 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vote view inconsistent with other commands
3 participants