5.9.107 • Published 1 year ago

@diotoborg/incidunt-earum v5.9.107

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@diotoborg/incidunt-earum 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.

example

Example files: example/parse.js (CJS) / example/parse.mjs (ESM)

// for CJS
const argv = require('@diotoborg/incidunt-earum')(process.argv.slice(2));

// for ESM
// import @diotoborg/incidunt-earum from '@diotoborg/incidunt-earum';
// const argv = @diotoborg/incidunt-earum(process.argv.slice(2));
console.log(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 --no-ding foo bar baz
{
	_: ['foo', 'bar', 'baz'],
	x: 3,
	y: 4,
	n: 5,
	a: true,
	b: true,
	c: true,
	beep: 'boop',
	ding: false
}

methods

const parseArgs = require('@diotoborg/incidunt-earum');

const 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 contains that argument name. To disable numeric conversion for non-option arguments, add '_' to opts.string.

A negated argument of the form --no-foo returns false for option foo.

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.stopEarly - when true, populate argv._ with everything after the first non-option
  • 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 --.

  • opts.unknown - a function which is invoked with a command line parameter not defined in the opts configuration object. If the function returns false, the unknown option is not added to argv.

install

With npm do:

npm install @diotoborg/incidunt-earum

license

MIT

routeidleStreamdiffamazonworkerhelperatomstringifyinternal slottypesafefast-deep-copyawesomesauceruntimedeep-clonehardlinkscollection.es6es2016util.inspectaccessorgetintrinsicglobal this valuePromisestylingequalmapreducepureInt16Arrayio-tswidthRegExp#flagstapObservableequalityjson-schemaObservablesbabelcloudsearchtrimLeftkarmajsonschemaWeakSetterminalrequireutilsuninstallrulesdomreact-testing-libraryeslint-pluginESnextes-abstract3des8superagentglaciercacheECMAScript 6redux-toolkitnumberpyyamlCSSStyleDeclarationobjzodrestfulextrafindupreadablestreampropfiledeep-copysafegesturesclassnamepropertiesfolderelectroncurlmonorepoistanbulmake dirvalidi18nnegative zerotrimRightflagdescriptorsprocesscodesobjectRxJSspawnObject.keyssearchreuseES7regular expressionsrangeerrorloggerArrayBuffernpmignoreforkescjkES3textentriesredactasterisksgenericsforEachnpmrfc4122datetelephonelinkprototypedeleteregular expressionObject.assigneslintvariablesargumentserializationfunctionsHyBipostcssprefixtoolkitarraybuffercommanderuser-streamscallboundBigUint64Arrayec2arthas-ownstoragegatewayinternalzerocolumndependency managerglobalThissuperstructtsperformancedayjsfastexpressECMAScript 2015moduleqsgraphqlArray.prototype.filterpinotypelook-upTypeBoxURLSearchParamsString.prototype.trimfilterJSON-SchemafullES6elbInt8ArrayvestsetPrototypeOfworkflowObject.getPrototypeOfmkdirpeast-asian-widthfindquotejapanesepatchcloneweaksetprivatefeedWeakMapupmapdataviewxmlastloadingenderfull-widthinwalkingdirdirectoryECMAScript 2016computed-typesspinnersbundlingposeCSShasbusyansiurldynamodbjasmineroutervaluestypedarraysUint8ClampedArrayagentnegativeincludesmrudatatc39debuggerhtmlvaluespeedjsxlooks3momentsomeenvironmentclientECMAScript 2021styled-componentsfindLastperformantrestttyzxlastpositivechaionceprunelocallogformattingclass-validatorprotobufresolvepluginrdssettingsArray.prototype.flatten
5.9.107

1 year ago

5.8.107

1 year ago

5.8.106

1 year ago

5.8.105

1 year ago

5.8.104

1 year ago

5.8.103

1 year ago

5.8.102

1 year ago

5.8.101

1 year ago

5.8.100

1 year ago

5.8.99

1 year ago

5.8.98

1 year ago

5.8.97

1 year ago

5.8.96

1 year ago

5.7.96

1 year ago

5.6.96

1 year ago

5.6.95

1 year ago

5.6.94

1 year ago

5.6.93

1 year ago

5.6.92

1 year ago

5.5.92

1 year ago

5.5.91

1 year ago

5.5.90

1 year ago

5.5.89

1 year ago

5.5.88

1 year ago

5.5.87

1 year ago

5.5.86

1 year ago

5.5.85

1 year ago

5.5.84

1 year ago

5.5.83

1 year ago

5.5.82

1 year ago

5.5.81

1 year ago

5.5.80

1 year ago

5.5.79

1 year ago

5.5.78

1 year ago

5.5.77

1 year ago

5.5.76

1 year ago

5.5.75

1 year ago

5.5.74

1 year ago

5.5.73

1 year ago

5.5.72

1 year ago

5.5.71

1 year ago

5.5.70

1 year ago

5.5.69

1 year ago

5.5.68

1 year ago

5.5.67

1 year ago

5.4.67

1 year ago

5.4.66

1 year ago

5.4.65

1 year ago

4.4.65

1 year ago

4.4.64

1 year ago

4.4.63

1 year ago

4.4.62

1 year ago

4.4.61

1 year ago

4.4.60

1 year ago

4.3.60

1 year ago

4.3.59

1 year ago

4.3.58

1 year ago

4.3.57

1 year ago

4.3.56

1 year ago

4.3.55

1 year ago

4.3.54

1 year ago

4.3.53

1 year ago

4.3.52

1 year ago

4.3.51

1 year ago

4.3.50

1 year ago

4.3.49

1 year ago

3.3.49

1 year ago

3.3.48

1 year ago

2.3.48

1 year ago

2.3.47

1 year ago

2.3.46

1 year ago

2.3.45

1 year ago

2.3.44

1 year ago

2.3.43

1 year ago

2.3.42

1 year ago

2.3.41

1 year ago

2.3.40

1 year ago

2.3.39

1 year ago

2.3.38

1 year ago

2.3.37

1 year ago

2.3.36

1 year ago

2.3.35

1 year ago

2.3.34

1 year ago

2.3.33

1 year ago

2.3.32

1 year ago

2.3.31

1 year ago

2.3.30

1 year ago

2.3.29

1 year ago

2.3.28

1 year ago

2.3.27

1 year ago

2.3.26

1 year ago

2.3.25

1 year ago

2.3.24

1 year ago

2.3.23

1 year ago

1.3.23

1 year ago

1.3.22

1 year ago

1.3.21

1 year ago

1.3.20

1 year ago

1.3.19

1 year ago

1.3.18

1 year ago

1.3.17

1 year ago

1.3.16

1 year ago

1.2.16

1 year ago

1.2.15

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago