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): conflicting arguments will error #64

Merged
merged 1 commit into from
Feb 10, 2020

Conversation

lirantal
Copy link
Owner

@lirantal lirantal commented Feb 8, 2020

Description

When incompatible CLI arguments are provided they shouldn't just be ignored and lead to failure but rather a proper message should be provided to users.

Types of changes

Detecting the conflicting use of both --allowed-schemes and --validate-https and error'ing out with specifying that only one of those should be used.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Related Issue

Fixes #63

Motivation and Context

Provides a better CLI experience for users.

How Has This Been Tested?

Added a CLI test.

Screenshots (if appropriate):

image

Checklist:

  • I have updated the documentation (if required).
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I added a picture of a cute animal cause it's fun

@lirantal lirantal added the enhancement New feature or request label Feb 8, 2020
@lirantal lirantal self-assigned this Feb 8, 2020
@lirantal lirantal added bug Something isn't working and removed enhancement New feature or request labels Feb 8, 2020
@codecov-io
Copy link

codecov-io commented Feb 8, 2020

Codecov Report

Merging #64 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #64   +/-   ##
=======================================
  Coverage   95.08%   95.08%           
=======================================
  Files          11       11           
  Lines         183      183           
  Branches       29       29           
=======================================
  Hits          174      174           
  Misses          8        8           
  Partials        1        1
Impacted Files Coverage Δ
packages/lockfile-lint/src/cli.js 0% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e76c88...53d57ba. Read the comment docs.

@lirantal lirantal merged commit 2d451c9 into master Feb 10, 2020
@XhmikosR
Copy link
Contributor

BTW @lirantal maybe this is considered a breaking change for some :)

That being said, the error message isn't 100% correct IMO.

I was using this command:

lockfile-lint --allowed-hosts npm --allowed-schemes https: --empty-hostname false --validate-https --type npm --path package-lock.json

and the error message I got was:

Arguments o and validate-https are mutually exclusive

But I didn't use the -o flag, I used --allowed-schemes

@lirantal
Copy link
Owner Author

@XhmikosR correct about the possible breaking-change so I'm reverting #65 and will merge as a breaking change.

about your case: -o and --allowed-schemes are the same options, it's the shortname and the alias for it:

Usage: lockfile-lint --path <path-to-lockfile> --allowed-hosts yarn npm

Options:
  --version              Show version number                           [boolean]
  --help, -h             Show help                                     [boolean]
  -p, --path             path to the lockfile                [string] [required]
  -t, --type             lockfile type, options are "npm" or "yarn"     [string]
  -s, --validate-https   validates the use of HTTPS as protocol schema for all
                         resources                                     [boolean]
  -e, --empty-hostname   allows empty hostnames, or set to false if you wish for
                         a stricter policy             [boolean] [default: true]
  -a, --allowed-hosts    validates a whitelist of allowed hosts to be used for
                         resources in the lockfile                       [array]
  -o, --allowed-schemes  validates a whitelist of allowed schemes to be used for
                         resources in the lockfile                       [array]

@XhmikosR
Copy link
Contributor

I know but it's a little confusing since I didn't pass -o :)

@lirantal
Copy link
Owner Author

Totally understood :-)
Will tweak out yargs as much as I can :)

lirantal added a commit that referenced this pull request Feb 10, 2020
@lirantal lirantal deleted the fix/conflicting-cli-arguments branch February 19, 2020 19:20
@lirantal lirantal restored the fix/conflicting-cli-arguments branch February 19, 2020 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extra check for incompatible options
3 participants