parse-cmd-args
TypeScript icon, indicating that this package has built-in type declarations

4.1.0 • Public • Published

parse-cmd-args

Returns an object containing the path and flags parsed from process.argv

NPM Version

Install

$ npm install parse-cmd-args --save

Usage

import { readFileSync } from 'fs';

import parseCmdArgs from 'parse-cmd-args';

const args = parseCmdArgs(null, {
  requireUserInput: true
});

if (args.flags['--version'] || args.flags['-v']) {
  process.stdout.write(
    `${JSON.parse(readFileSync('./package.json', 'utf8')).version}\n`
  );
  process.exit();
} else if (args.flags['--help'] || args.flags['-h']) {
  process.stdout.write('Usage: \n');
  process.exit();
}

console.log(args);

Readme

Keywords

Package Sidebar

Install

npm i parse-cmd-args

Weekly Downloads

260

Version

4.1.0

License

MIT

Unpacked Size

9.3 kB

Total Files

6

Last publish

Collaborators

  • neogeek