Skip to content

Releases: webdiscus/flaget

v2.1.1

16 Jul 10:32
89ec2ab

Choose a tag to compare

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

08 Jul 19:42
a1d5708

Choose a tag to compare

⚠️ 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 args option for named positional arguments
  • Added support for variadic arguments (e.g. ...files) to collect last arguments into array
  • Added boolean option to treat flags as booleans without consuming values
  • Return property _ now contains only positional arguments before --
  • Added return property _tail to capture all arguments after --

v1.1.0

06 Jul 21:18
840747a

Choose a tag to compare

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=value or --key value
  • Dashed long flag: --foo-bar (available as both flags['foo-bar'] and flags.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