From d5b404a4091534b3e839a849559442754fdb3779 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 29 Apr 2023 09:55:22 +0300 Subject: [PATCH] Improve CLI --- bin/cli.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index 6f0bedc..6e300df 100644 --- a/bin/cli.js +++ b/bin/cli.js @@ -5,21 +5,24 @@ const fs = require('fs'); const program = require('commander'); const precinct = require('../index.js'); -const { version } = require('../package.json'); +const { name, description, version } = require('../package.json'); program - .arguments('') + .name(name) + .description(description) .version(version) + .argument('', 'the path to file to examine') .option('--es6-mixed-imports', 'Fetch all dependendies from a file that contains both CJS and ES6 imports') .option('-t, --type ', 'The type of content being passed in. Useful if you want to use a non-JS detective') + .showHelpAfterError() .parse(); -const cliOptions = program.opts(); +const { es6MixedImports: mixedImports, type } = program.opts(); const options = { es6: { - mixedImports: Boolean(cliOptions.es6MixedImports) + mixedImports: Boolean(mixedImports) }, - type: cliOptions.type + type }; const content = fs.readFileSync(program.args[0], 'utf8');