Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
tiny-parse-argv
Advanced tools
A tiny function for parsing process.argv, a modern rewrite of a sensible subset of minimist.
A tiny function for parsing process.argv
, a modern rewrite of a sensible subset of minimist
.
The following features are provided:
-f
, -f some
, -f 123
, -f123
, -abc
, -abc 123
, -abc123
, -f some -f other
.--foo
, --foo some
, --foo 123
, --foo=123
, --foo=some
, --foo some --foo other
.false
by default: --no-foo
, --no-bar
../app.sh with some list of arguments
.options.boolean
: the value for the listed flags will always be coerced to a boolean.options.string
: the value for the listed flags will always be coerced to a string.options.alias
: if any aliased flag is assigned then all the aliases for it will be assigned too, automatically.options.default
: an object containing default values, which will be used if not overridded by the argv
array.--
: a special flag that stops parsing, everything after it will be copied, untouched, into the --
property of the return object.minimist
The following differences exist compared to minimist
:
option['--']
set to false
is not supported, it's as if it's always set to true
.option.boolean
set to true
is not supported, you should always explicitly list all your supported boolean flags instead.option.boolean
set to a single string is not supported, always provide an array of flags instead.option.string
set to a single string is not supported, always provide an array of flags instead.option.alias
mapping to a single string is not supported, always provide an array of aliases instead.option.unknown
is not supported, you should handle unknown flags at another level of abstraction.option.stopEarly
is not supported, it's as if it's always set to false
.path-prop
's unflat
function for that.Other than that it should work pretty much identically, since we are basically using the same tests.
npm install --save tiny-parse-argv
import parseArgv from 'tiny-parse-argv';
parseArgv ([ '-f', '--foo', 'some', 'argument', '--', '--app-flag' ]);
// => { f: true, foo: 'some', _: ['argument'], '--': ['--app-flag'] }
MIT © Fabio Spampinato
FAQs
A tiny function for parsing process.argv, a modern rewrite of a sensible subset of minimist.
The npm package tiny-parse-argv receives a total of 17,262 weekly downloads. As such, tiny-parse-argv popularity was classified as popular.
We found that tiny-parse-argv demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.