Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

feat(cli): add user-friendly exit for unknown options #854

Merged
merged 1 commit into from
Nov 18, 2021

Conversation

nozomuikuta
Copy link
Contributor

@nozomuikuta nozomuikuta commented Sep 21, 2021

This PR has no related issues.

I added a logic for CNA to show help message instead of raw error stack in case a user (like me 1 hour ago) passes unknown options.
By doing so, the user can find what he/she really wanted and copy it quickly, without running help command or seeing documentation.


Explanation of work

I felt the try-catch block long so I extracted the main part in run function.
If you prefer inlined version as before, let me know.

How I tested

  1. Ran node lib/cli.js test --unknown-options, and checked the output (for what I added)
  2. Ran node lib/cli.js test with throw new Error('Custom Message') added before run function call, and checked the output (for backward compatibility)
  3. Ran node lib/cli.js test, and checked the output (for backward compatibility, it shows "not empty" error with exit code 0)

@clarkdo clarkdo changed the title chore(cli): add user-friendly exit for unknown options feat(cli): add user-friendly exit for unknown options Sep 22, 2021
@clarkdo clarkdo merged commit b734105 into nuxt:master Nov 18, 2021
@nozomuikuta nozomuikuta deleted the chore/user-friendly-exit branch November 18, 2021 15:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants