1.2.8 • Published 1 year ago

minimist v1.2.8

Weekly downloads
41,784,005
License
MIT
Repository
github
Last release
1 year ago

minimist Version Badge

github actions coverage License Downloads

npm badge

parse argument options

This module is the guts of optimist's argument parser without all the fanciful decoration.

browser support

build status

example

var argv = require('minimist')(process.argv.slice(2));
console.dir(argv);
$ node example/parse.js -a beep -b boop
{ _: [], a: 'beep', b: 'boop' }
$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
{ _: [ 'foo', 'bar', 'baz' ],
  x: 3,
  y: 4,
  n: 5,
  a: true,
  b: true,
  c: true,
  beep: 'boop' }

methods

var parseArgs = require('minimist')

var argv = parseArgs(args, opts={})

Return an argument object argv populated with the array arguments from args.

argv._ contains all the arguments that didn't have an option associated with them.

Numeric-looking arguments will be returned as numbers unless opts.string or opts.boolean is set for that argument name.

Any arguments after '--' will not be parsed and will end up in argv._.

options can be:

  • opts.string - a string or array of strings argument names to always treat as strings
  • opts.boolean - a boolean, string or array of strings to always treat as booleans. if true will treat all double hyphenated arguments without equal signs as boolean (e.g. affects --foo, not -f or --foo=bar)
  • opts.alias - an object mapping string names to strings or arrays of string argument names to use as aliases
  • opts.default - an object mapping string argument names to default values
  • opts['--'] - when true, populate argv._ with everything before the -- and argv['--'] with everything after the --. Here's an example:
> require('./')('one two three -- four five --six'.split(' '), { '--': true })
{ _: [ 'one', 'two', 'three' ],
  '--': [ 'four', 'five', '--six' ] }

Note that with opts['--'] set, parsing for arguments still stops after the --.

install

With npm do:

npm install minimist

license

MIT

rcsane@cnakazawa/watchhandlebarstsconfig-pathsecstaticoptimisthttp-serverprebuild-installgonzales-pedetectivecypressgulp-utilstrong-log-transformersubargwait-onwatchblocking-proxy@withcardinal/sql@withcardinal/tapwxtest-ci-zjyxaf-crate-reborn@build-tools-for-vmware-aria/codifyfork-appcenter-clifront-end-app-template@alzhan/rncore-commands@allview-cli/core@hd-ui/cli@mace/ng-admin@sishenma/create-tpl@simosol/mapbox-gl-js-offline@process-engine/process_engine_runtime@slp/ng-admin@mxw/devkit@navify/cli-framework@pnp/cli-microsoft365@neuvernetzung/cms-cli@huyhpham/rn-line@zhyao1684-cli/core@the-api-builder/cli@pulumi/pulumi@rockolin/git-pull-code@serverless/components@hotfusion/typer@ilscc/mrm-preset@imohuan-dev/cli@hn-ui/cliapod-bgagc-integration-testsadspilot-uiaenft-collectioncreate-pickcreate-by-templatearchetype-libraryapp-generator-tzhbpmn-studiobrowserstack-screen-fetch@by-ac/browser-auth@contiago/toolbar@cli-zx-test/core@germanamz/pack-lambda@def-builder/core@hazymoon-cli-dev/corecreate-mrcen-clicrowdmarkcreate-upvitetestcommit-cz-fixcreate-czyvitecreate-devkitcreate-baxiacomponennenttcomplydiff-a-json@omnia/tooling@atlas-engine/fullstack_server@datagrok/metaeasy-select-rn@gkasdorf/imgurify@saasxx/cli@saasxx/cli-runtime@ishopee/cli-service@ishopee/create-vite-appchinjowwchinjow@weweb/createdhruw-hello-clibunny-the-bundlerget-graphql-schema-testfitpconvert-csv-to-resxweather-sal@mughalhere/gql-generatorcreate-loui-applockit-secrets-test2lockit-secrets-test3@aymlab/mortarwx-fee-clibrokerapipopsmart-common-authreact-native-bluetooth2
1.2.8

1 year ago

0.2.3

1 year ago

0.2.4

1 year ago

1.2.7

2 years ago

0.2.2

2 years ago

1.2.6

2 years ago

1.2.5

4 years ago

0.2.1

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago

0.0.0

11 years ago