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

Fix CLI -h to display default values (#4400) #4402

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

Delusion2056
Copy link
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Args and Options in @effect/cli did not correctly display default values in the help output when withDefault was used. If the fallback value was wrapped in Option.some, the internal object details were printed instead of the expected default value.

Fix attempted is:

  • Coerce primitive fallback values to strings for proper display.
  • Serialize non-primitive fallback values to (compact-style) JSON using the effect/Inspectable module.
  • This ensures that both Args and Options display expected default values in their help output.

A few basic test cases were added for both Args and Options. Snapshots used due to deep partial object matching getting messy without custom matchers. (Unless I missed something.)

Related

@Delusion2056 Delusion2056 requested a review from IMax153 as a code owner February 5, 2025 07:08
Copy link

changeset-bot bot commented Feb 5, 2025

🦋 Changeset detected

Latest commit: f2f14f8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@IMax153 IMax153 left a comment

Choose a reason for hiding this comment

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

This change looks great @Delusion2056 ! Thank you so much for the PR and the help with this :)

@IMax153 IMax153 merged commit 3e56745 into Effect-TS:main Feb 6, 2025
12 checks passed
@github-actions github-actions bot mentioned this pull request Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

From Discord: Default Value Not Displayed in CLI Usage for Args.withDefault
2 participants