包详细信息

parse-cmd-args

neogeek13.8kMIT5.0.2

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

parse, cmd, args

自述文件

parse-cmd-args

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

Test Publish Documentation NPM version

Install

$ npm install parse-cmd-args --save

Usage

import { readFile } from 'node:fs/promises';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

import parseCmdArgs from 'parse-cmd-args';

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

if (args.flags['--version'] || args.flags['-v']) {
  process.stdout.write(
    `${
      JSON.parse(
        async readFile(
          join(dirname(fileURLToPath(import.meta.url)), '../package.json'),
          'utf8'
        )
      ).version
    }\n`
  );
  process.exit();
} else if (args.flags['--help'] || args.flags['-h']) {
  process.stdout.write(`Usage: example <path> ... [options]

  Options:

   -h, --help         Display this help message.
   -v, --version      Display the current installed version.
`);
  process.exit();
}

console.log(args);

更新日志

Changelog

v5.0.2 - (2024-05-07)

Full Changelog

  • [hotfix] Fixed import path. #45
  • [hotfix] Updated packages. #44

v5.0.1 - (2024-04-26)

Full Changelog

  • [hotfix] Fixed publish workflow to build before publish. #43

v5.0.0 - (2024-04-26)

Full Changelog

  • [hotfix] Updated packages. #42
  • [feat] Added types. #40

v4.1.0 - (2022-03-26)

Full Changelog

  • [feat] Capture raw inputs. #39

v4.0.0 - (2022-02-07)

Full Changelog

  • [feat] Converted package to TypeScript. #38

v3.0.0 - (2020-09-11)

Full Changelog

  • chore(package): update mocha to version 4.0.1 #32
  • Update codecov to the latest version 🚀 #31
  • chore(package): update mocha to version 4.0.1 #30
  • Update @neogeek/eslint-config-standards to the latest version 🚀 #28
  • chore(package): update eslint to version 4.2.0 #29
  • chore(package): update eslint to version 4.2.0 #27
  • Update @neogeek/eslint-config-standards to the latest version 🚀 #25
  • Update eslint to the latest version 🚀 #23
  • Update codecov to the latest version 🚀 #24
  • Update codecov to the latest version 🚀 #22
  • Update codecov to the latest version 🚀 #21
  • Update @neogeek/eslint-config-standards to the latest version 🚀 #19
  • chore(package): update eslint to version 3.17.1 #20
  • chore(package): update eslint to version 3.17.1 #18
  • chore(package): update eslint to version 3.16.1 #17
  • Update @neogeek/eslint-config-standards to the latest version 🚀 #16
  • chore(package): update eslint to version 3.16.1 #15
  • Update dependencies to enable Greenkeeper 🌴 #14
  • Update doxdox to version 2.0.0 🚀 #11
  • Update mocha to version 3.2.0 🚀 #8
  • Update eslint to version 3.9.1 🚀 #7
  • Update doxdox to version 1.1.0 🚀 #4

v2.0.0 - (2016-10-25)

Full Changelog

  • Update eslint to version 3.8.1 🚀 #1
  • Update doxdox to version 1.0.1 🚀 #3

v1.0.2 - (2016-10-16)

Full Changelog

  • No merges found

v1.0.1 - (2016-10-15)

Full Changelog

  • No merges found

v1.0.0 - (2016-10-14)

  • Initial release! 🎉

This changelog was generated with generate-local-changelog