Skip to content

Commit

Permalink
feat: migrate to yargs
Browse files Browse the repository at this point in the history
  • Loading branch information
de-don committed Sep 12, 2024
1 parent d0f97fa commit 7ad1c6b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
50 changes: 22 additions & 28 deletions bin/pjv
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,34 @@
*/

// Command line options
var args = require('optimist')
.options('filename', {
var options = require("yargs/yargs")(process.argv.slice(2))
.options("filename", {
"default": "package.json",
"alias": 'f'
}).describe('filename', 'package.json file to validate')
.options('spec', {
"alias": "f",
"description": "package.json file to validate",
})
.options("spec", {
"default": "npm",
"alias": 's'
}).describe('spec', 'which spec to use - npm|commonjs_1.0|commonjs_1.1')
.options('warnings', {
"alias": "s",
"description": "spec to use - npm|commonjs_1.0|commonjs_1.1",
})
.options("warnings", {
"default": false,
"alias": 'w'
}).describe('warnings', 'display warnings')
.options('recommendations', {
"alias": "w",
"description": "display warnings",
})
.options("recommendations", {
"default": false,
"alias": 'r'
}).describe('recommendations', 'display recommendations')
.options('quiet', {
"alias": "r",
"description": "display recommendations",
})
.options("quiet", {
"default": false,
"alias": 'q'
}).describe('quiet', 'less output')
"alias": "q",
"description": "less output",
})
.usage("Validate package.json files")
.options('help', {
"default": false,
"alias": 'h'
}).describe('help', 'this help message')
.alias('help', '?');

var options = args.argv;

if (options.help) {
args.showHelp();
process.exit(0);
}
.parse();

var PJV = require('../PJV').PJV;
var fs = require('fs');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"email": "[email protected]"
},
"dependencies": {
"optimist": "~0.6.0"
"yargs": "~17.7.2"
},
"devDependencies": {
"grunt": "~0.4.1",
Expand Down

0 comments on commit 7ad1c6b

Please sign in to comment.