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: move cli leven suggestion to options-normalizer #5057

Merged
merged 2 commits into from Sep 7, 2018

Conversation

Projects
None yet
3 participants
@ikatyang
Member

ikatyang commented Sep 5, 2018

Option-related processing should be done in options-normalizer.

  • unknown flag suggestions are colored
    image
  • unknown flags with no suggestion are now errors:
    $ bin/prettier.js --help noseminosemi
    [error] Invalid `--help` value. Expected `a flag`, but received `"noseminosemi"`.
    

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory)
  • I’ve read the contributing guidelines.
@@ -311,6 +296,15 @@ exports[`throw error with --find-config-path + multiple files (stdout) 1`] = `""
exports[`throw error with --find-config-path + multiple files (write) 1`] = `Array []`;
exports[`throw error with --help not-found (stderr) 1`] = `
"[error] Invalid --help value. Expected \\"arrow-parens\\", \\"bracket-spacing\\", \\"color\\", \\"config\\", \\"config-precedence\\", \\"cursor-offset\\", \\"editorconfig\\", \\"file-info\\", \\"find-config-path\\", \\"h\\", \\"help\\", \\"ignore-path\\", \\"insert-pragma\\", \\"jsx-bracket-same-line\\", \\"l\\", \\"list-different\\", \\"loglevel\\", \\"no-bracket-spacing\\", \\"no-color\\", \\"no-config\\", \\"no-editorconfig\\", \\"no-semi\\", \\"parser\\", \\"plugin\\", \\"plugin-search-dir\\", \\"print-width\\", \\"prose-wrap\\", \\"range-end\\", \\"range-start\\", \\"require-pragma\\", \\"semi\\", \\"single-quote\\", \\"stdin\\", \\"stdin-filepath\\", \\"support-info\\", \\"tab-width\\", \\"trailing-comma\\", \\"use-tabs\\", \\"v\\", \\"version\\", \\"with-node-modules\\" or \\"write\\", but received \\"not-found\\".

This comment has been minimized.

@j-f1

j-f1 Sep 5, 2018

Member

Would it be easy to make this into a bulleted list? I feel like it would be easier to read that way.

This comment has been minimized.

@ikatyang

ikatyang Sep 6, 2018

Member

Ref: ikatyang/vnopts#9

Something like this?

image

This comment has been minimized.

@j-f1

j-f1 Sep 6, 2018

Member

That looks great!

This comment has been minimized.

@duailibe

duailibe Sep 6, 2018

Member

I personally wouldn't show every option available.. in this case, I'd just show "Invalid --help value"

This comment has been minimized.

@j-f1

j-f1 Sep 6, 2018

Member

Perhaps “Invalid --help value, expected an option name but got X.”?

This comment has been minimized.

@ikatyang

ikatyang Sep 7, 2018

Member

Since we called it flag in the usage, "expected a flag" should be better I think?

-h, --help <flag> Show CLI usage, or details about the given flag.
Example: --help write

@j-f1

j-f1 approved these changes Sep 7, 2018

@ikatyang ikatyang merged commit 4ff0f26 into prettier:master Sep 7, 2018

10 checks passed

ci/circleci: build_prod Your tests passed on CircleCI!
Details
ci/circleci: checkout_code Your tests passed on CircleCI!
Details
ci/circleci: test_prod_node4 Your tests passed on CircleCI!
Details
ci/circleci: test_prod_node9 Your tests passed on CircleCI!
Details
ci/circleci: test_prod_standalone Your tests passed on CircleCI!
Details
codecov/patch 100% of diff hit (target 80%)
Details
codecov/project Absolute coverage decreased by -0.29% but relative coverage increased by +3.44% compared to a1545a8
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details

@ikatyang ikatyang deleted the ikatyang:refactor/move-cli-leven branch Sep 7, 2018

@ikatyang ikatyang added this to the 1.15 milestone Oct 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment