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

refactor: Simplify CLI flag validation #1699

Merged
merged 1 commit into from Nov 19, 2022
Merged

Conversation

rschristian
Copy link
Member

@rschristian rschristian commented Jun 7, 2022

What kind of change does this PR introduce?

Refactor

Did you add tests for your changes?

Adjusted one, yes.

Larger test changes were extracted to #1738 because this diff was rather large and I wanted to use base other work off of both of these independently.

Summary

Partial revert of #1467

sade has a builtin mechanism for catching unknown options being passed to it, allowing us to simplify things a bit.

There should be no functional changes here at all.

Does this PR introduce a breaking change?

No

@changeset-bot
Copy link

changeset-bot bot commented Jun 7, 2022

⚠️ No Changeset found

Latest commit: 7b6b007

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

packages/cli/lib/index.js Outdated Show resolved Hide resolved
packages/cli/lib/index.js Outdated Show resolved Hide resolved
packages/cli/lib/util.js Outdated Show resolved Hide resolved
@rschristian rschristian marked this pull request as ready for review June 15, 2022 08:40
@rschristian rschristian requested a review from a team as a code owner June 15, 2022 08:40
@rschristian rschristian changed the title refactor: argument/flag validation refactor: remove long-broken flags and simplify validation Jun 15, 2022
@rschristian rschristian changed the title refactor: remove long-broken flags and simplify validation refactor: Simplify CLI flag validation & add more tests Jul 10, 2022
@rschristian rschristian marked this pull request as draft July 10, 2022 04:09
@rschristian rschristian force-pushed the refactor/invalid-args branch 2 times, most recently from ee68207 to 80a1037 Compare July 10, 2022 04:15
@rschristian rschristian marked this pull request as ready for review July 10, 2022 04:17
@rschristian rschristian force-pushed the refactor/invalid-args branch 3 times, most recently from 84e8307 to c28c4fd Compare August 21, 2022 05:52
@rschristian rschristian changed the title refactor: Simplify CLI flag validation & add more tests refactor: Simplify CLI flag validation Aug 21, 2022
});
buildCommand.action(commands.build);
)
.option('--src', 'Specify source directory', 'src')
Copy link
Member

Choose a reason for hiding this comment

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

I think I remember it originally being done this way, but I don't know why it was changed to the version it currently is

Probably older than the new sade option

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, we had the commands in this format but I think sade's option was just missed, so validation was done the way it was. It's a pretty long ReadMe without a table of contents, easy enough to do.

Alternatively, maybe there was an idea for better type checking on args down the road? sade/mri are a bit "loose" with coercing input types, leading to a few odd situations. Just guessing though; if we wanted to do that there's probably simpler ways to validate the schema than this setup.

@rschristian rschristian merged commit 735b72e into master Nov 19, 2022
@rschristian rschristian deleted the refactor/invalid-args branch November 19, 2022 00:24
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.

None yet

2 participants