Skip to content

Depend on optparse-applicative instead of optparse-applicative-fork#899

Closed
smelc wants to merge 3 commits intomasterfrom
smelc/use-vanilla-optparse-applicative
Closed

Depend on optparse-applicative instead of optparse-applicative-fork#899
smelc wants to merge 3 commits intomasterfrom
smelc/use-vanilla-optparse-applicative

Conversation

@smelc
Copy link
Contributor

@smelc smelc commented Sep 18, 2024

Note

Requires a release of optparse-applicative > 0.18.1 to be merged

Changelog

- description: |
    Depend on optparse-applicative instead of optparse-applicative-fork
# 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
  - refactoring    # QoL changes
  # - 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

We want to get rid on our dependency to optparse-applicative-fork here: cardano-cli/cardano-cli.cabal#L245.

This PR does this, as well as showing what it happens if we take a vanilla version of optparse-applicative. This is what the commit Changes to golden files WITHOUT change to optparse-applicative shows.

Then the last commit, named Changes to golden files WITH change to optparse-applicative shows what we can achieve if we tweak optparse-applicative slightly. In this case the changes to golden files is minimal (pipes move to the left, and then are more single line disjunctions, but they are fine IMHO).

How to trust this PR

Look at the golden files. See that the end state is quite nice.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • Self-reviewed the diff

[ showHelpOnEmpty
, helpEmbedBriefDesc PP.align
, helpRenderHelp customRenderHelp
-- , helpEmbedBriefDesc PP.align
Copy link
Contributor Author

@smelc smelc Sep 18, 2024

Choose a reason for hiding this comment

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

This PP.align value is the magical configuration bit that makes the golden files still look good. The changes in https://github.com/smelc/optparse-applicative/commits/smelc/wip-cardano-cli-usecase/ are hardcoding this configuration change for now, but my plan is to make a PR to optparse-applicative to make this configurable.

@smelc smelc force-pushed the smelc/use-vanilla-optparse-applicative branch from bed54fc to 3be2b7c Compare September 18, 2024 11:04
@smelc smelc force-pushed the smelc/use-vanilla-optparse-applicative branch 3 times, most recently from c7ed606 to 62b33cc Compare September 18, 2024 14:55
@smelc smelc force-pushed the smelc/use-vanilla-optparse-applicative branch 4 times, most recently from 7d32504 to 13cfd22 Compare November 4, 2024 11:09
@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@smelc
Copy link
Contributor Author

smelc commented Mar 18, 2025

Because optparse-applicative should be released soon, we should be able to merge this PR soonish.

That is why I'm assigning it to you @nbacquey 🙂

@smelc
Copy link
Contributor Author

smelc commented Apr 3, 2025

This will be mergeable soon: pcapriotti/optparse-applicative#494 (comment)

cc @carbolymer @nbacquey

@smelc
Copy link
Contributor Author

smelc commented Jun 3, 2025

@github-actions

This comment was marked as outdated.

@github-actions github-actions bot added the Stale label Jul 24, 2025
@github-actions

This comment was marked as outdated.

@github-actions github-actions bot closed this Sep 23, 2025
@carbolymer carbolymer reopened this Oct 30, 2025
@carbolymer carbolymer force-pushed the smelc/use-vanilla-optparse-applicative branch from 13cfd22 to b3a5035 Compare October 30, 2025 10:36
@carbolymer carbolymer assigned carbolymer and unassigned nbacquey Oct 30, 2025
@carbolymer
Copy link
Contributor

carbolymer commented Oct 30, 2025

We're depending on cardano-addresses now, which depends on optparse-applicative. PR blocked on:

@carbolymer carbolymer force-pushed the smelc/use-vanilla-optparse-applicative branch from b3a5035 to 1394d07 Compare October 30, 2025 11:35
@carbolymer carbolymer marked this pull request as ready for review October 30, 2025 11:39
@carbolymer carbolymer force-pushed the smelc/use-vanilla-optparse-applicative branch from 1394d07 to d4a69a0 Compare October 30, 2025 11:39
@carbolymer carbolymer force-pushed the smelc/use-vanilla-optparse-applicative branch from d4a69a0 to d09207f Compare November 3, 2025 22:44
@carbolymer carbolymer requested a review from a team as a code owner November 3, 2025 22:44
@carbolymer carbolymer force-pushed the smelc/use-vanilla-optparse-applicative branch 3 times, most recently from 6b4f5c1 to 4d76418 Compare November 4, 2025 07:15
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

The change in the alignment is a decrease in readability IMO. Can we keep the previous alignment?

exitWith $ ExitFailure 1
)

renderAnyCmdError :: Text -> (a -> Doc ann) -> a -> Doc ann
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not import from Cardano.CLI.Type.Error.QueryCmdError?

| cip-format
| compatible
)
Usage: cardano-cli (address | key | node | hash | query | legacy | byron |
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want this formatting change cc: @CarlosLopezDeLara

]
--verification-key-file FILEPATH
--signing-key-file FILEPATH
Usage: cardano-cli address key-gen [--key-output-bech32 |
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a decrease in readability.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Jimbo4350 @carbolymer

I agree.

I do like the compactness of things like:

Usage: cardano-cli conway query protocol-parameters [--cardano-mode [--epoch-slots SLOTS]] (--mainnet | --testnet-magic NATURAL) --socket-path SOCKET_PATH [--output-json | --output-yaml] [--out-file FILEPATH] 

But in the other hand, the build command and others with more complex options are far too messy

Screenshot_20251105_090244

Let's not merge this one. It was a good idea trying to remove the burden of maintaining the fork, but we loose readability.

@carbolymer carbolymer force-pushed the smelc/use-vanilla-optparse-applicative branch from f9e2513 to 5965db4 Compare November 6, 2025 12:19
@carbolymer
Copy link
Contributor

This PR results in decrease in readabilty, which seems to be not feasible to fix with the current version of optparse-applicative-fork-0.19.

@carbolymer carbolymer closed this Nov 6, 2025
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.

5 participants