A proxy for modifying modifying requests to Docker-compatible container requests on the fly. Bring your own custom behaviour through an extensive plugin-system.
Option.preset() allows specifying value/arg for option when used without option-argument (especially optional, but also boolean option) (#1652)
.executableDir() for custom search for subcommands (#1571)
throw with helpful message if pass Option to .option() or .requiredOption() (#1655)
.error() for generating errors from client code just like Commander generated errors, with support for .configureOutput (), .exitOverride(), and .showHelpAfterError() (#1675)
.optsWithGlobals() to return merged local and global options (#1671)
Changed
Breaking: Commander 9 requires Node.js v12.20.0 or higher
update package-lock.json to lockfile@2 format (#1659)
showSuggestionAfterError is now on by default (#1657)
Breaking: default value specified for boolean option now always used as default value (see .preset() to match some previous behaviours) (#1652)
default value for boolean option only shown in help if true/false (#1652)
use command name as prefix for subcommand stand-alone executable name (with fallback to script name for backwards compatibility) (#1571)
option with optional argument not supplied on command line now works when option already has a value, whether from default value or from previous arguments (#1652)
Removed
Breaking: removed internal fallback to require.main.filename when script not known from arguments passed to .parse()
(can supply details using .name(), and .executableDir() or executableFile) (#1571)
no longer needed as action handler is passed options and command
Breaking: "extra arguments" parameter to action handler (#1409)
if being used to detect excess arguments, there is now an error available by setting .allowExcessArguments(false)
Migration Tips
The biggest change is the parsed option values. Previously the options were stored by default as properties on the command object, and now the options are stored separately.
If you wish to restore the old behaviour and get running quickly you can call .storeOptionsAsProperties().
To allow you to move to the new code patterns incrementally, the action handler will be passed the command twice,
to match the new "options" and "command" parameters (see below).
program options
Use the .opts() method to access the options. This is available on any command but is used most with the program.
program.option('-d, --debug');program.parse();// Old code before Commander 7if(program.debug)console.log(`Program name is ${program.name()}`);
// New codeconstoptions=program.opts();if(options.debug)console.log(`Program name is ${program.name()}`);
action handler
The action handler gets passed a parameter for each command-argument you declared. Previously by default the next parameter was the command object with the options as properties. Now the next two parameters are instead the options and the command. If you
only accessed the options there may be no code changes required.
program.command('compress <filename>').option('-t, --trace')// Old code before Commander 7.action((filename,cmd))=>{if(cmd.trace)console.log(`Command name is ${cmd.name()}`);});
// New code.action((filename,options,command))=>{if(options.trace)console.log(`Command name is ${command.name()}`);});
If you already set .storeOptionsAsProperties(false) you may still need to adjust your code.
program.command('compress <filename>').storeOptionsAsProperties(false).option('-t, --trace')// Old code before Commander 7.action((filename,command))=>{if(command.opts().trace)console.log(`Command name is ${command.name()}`);});
// New code.action((filename,options,command))=>{if(command.opts().trace)console.log(`Command name is ${command.name()}`);});
Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with @depfu rebase.
All Depfu comment commands
@depfu rebase
Rebases against your default branch and redoes this update
@depfu recreate
Recreates this PR, overwriting any edits that you've made to it
@depfu merge
Merges this PR once your tests are passing and conflicts are resolved
@depfu close
Closes this PR and deletes the branch
@depfu reopen
Restores the branch and reopens this PR (if it's closed)
@depfu pause
Ignores all future updates for this dependency and closes this PR
@depfu pause [minor|major]
Ignores all future minor/major updates for this dependency and closes this PR
@depfu resume
Future versions of this dependency will create PRs again (leaves this PR as is)
Here is everything you need to know about this upgrade. Please take a good look at what changed and the test results before merging this pull request.
What changed?
✳️ commander (6.2.1 → 9.2.0) · Repo · Changelog
Release Notes
9.2.0
9.1.0
9.0.0
8.3.0
8.2.0
8.1.0
8.0.0
7.2.0
7.1.0
7.0.0
Does any of this look wrong? Please let us know.
Commits
See the full diff on Github. The new version differs by more commits than we can show here.
Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with
@depfu rebase
.All Depfu comment commands