@putout/cli-validate-args

1.1.1 • Public • Published

@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

Package Sidebar

Install

npm i @putout/cli-validate-args

Weekly Downloads

5,910

Version

1.1.1

License

MIT

Unpacked Size

4.6 kB

Total Files

4

Last publish

Collaborators

  • coderaiser