t, -timeout timeout in seconds (default: one minute) addOption(new Option('-p, -port ', 'port number').env('PORT')) addOption(new Option('-d, -drink ', 'drink size').choices()) addOption(new Option('-t, -timeout ', 'timeout in seconds').default(60, 'one minute')) addOption(new Option('-s, -secret').hideHelp()) option() method, but there are some additional features availableīy constructing an Option explicitly for less common cases.Įxample files: options-extra.js, options-env.js program program.version('0.0.1', '-v, -vers', 'output the current version') The same syntax for flags as the option method. You may change the flags and description by passing additional parameters to the version method, using ![]() The default option flags are -V and -version, and when present the command prints the version number and exits. The optional version method adds handling for displaying the command version. const įor information about possible ambiguous cases, see options taking varying arguments. ![]() This is used in the examples in this README for brevity. Debugging stand-alone executable subcommandsįor information about terms used in this document see: terminology Installation npm install commanderĬommander exports a global object which is convenient for quick programs.Other option types, negatable boolean and boolean|value.Read this in other languages: English | 简体中文 The complete solution for node.js command-line interfaces.
0 Comments
Leave a Reply. |