Releases: webdiscus/flaget
Releases · webdiscus/flaget
v2.1.1
Features
- Added support negated flags with prefix
--no-, e.g.--no-color->{ color: false }. - Added support both CommonJS and ESM.
- Added support TypeScript.
- Added support TSC, compatible with
module: "Node16". - Improved performance.
- Reduced unpacked package size.
Chore
- Added benchmark, you can run it in
bench/directory, to compare with most popular alternatives:- mri
- nopt
- minimist
- yargs-parser
v2.0.0
⚠️ BREAKING CHANGES
Redesigned structure of return object with parsed elements
Example: cli.js --verbose file.txt -- one two
Old v1.x
Returns:
{
verbose: true,
_: ['file.txt', 'one', 'two'],
}New v2.x
Returns:
{
args: {}, // named positional arguments
flags: { verbose: true }, // parsed flags
_: ['file.txt'], // arguments before `--`
_tail: ['one', 'two'], // arguments after `--`
}✅ Features
- Added
argsoption for named positional arguments - Added support for variadic arguments (e.g.
...files) to collect last arguments into array - Added
booleanoption to treat flags as booleans without consuming values - Return property
_now contains only positional arguments before-- - Added return property
_tailto capture all arguments after--
v1.1.0
Features
- Short boolean flag:
-f - Short flag with value:
-f value - Grouped short flags:
-abc(equivalent to-a-b-c) - Long boolean flag:
--flag - Long flag with value:
--key=valueor--key value - Dashed long flag:
--foo-bar(available as bothflags['foo-bar']andflags.fooBar) - Multi-values:
--files a.js b.js - Short-to-long alias:
-f=--files - Positional arguments and
--terminator:cmd -a --key=foo baz -- qux - Default values for flags