Socket
Socket
Sign inDemoInstall

@putout/cli-validate-args

Package Overview
Dependencies
2
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @putout/cli-validate-args

validate args, sugest closest variant


Version published
Weekly downloads
16K
decreased by-12.8%
Maintainers
1
Install size
21.4 kB
Created
Weekly downloads
 

Readme

Source

@putout/cli-validate-args NPM version Dependency Status

Validate args and propose the closes variaint found by fastest-levenshtein:

Invalid option '--fi'. Perhaps you meant '--fix'`

.

Install

npm i @putout/cli-validate-args

Examples

// validate-args.js

import validateArgs from '@putout/cli-validate-args';
import parse from 'yargs-parser';

const argv = process.argv.slice(2);
const yargsConfig = {
    configuration: {
        'strip-aliased': true,
        'strip-dashed': true,
    },
    number: [
        "fix-count",
    ],
    boolean: [
        'fix',
    ],
};

const args = parse(argv, yargsConfig);

const error = await validateArgs(args, [
    ...yargsConfig.boolean,
    ...yargsConfig.number,
]);

if (error) {
    console.error(error.message);
    process.exit(1);
}
$ node validate-args.js --fi
Invalid option '--fi'. Perhaps you meant '--fix'`

License

MIT

Keywords

FAQs

Last updated on 05 Sep 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc