angular-slickgrid 4.2.1 → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/LICENSE +20 -20
  2. package/app/modules/angular-slickgrid/components/angular-slickgrid.component.d.ts +2 -2
  3. package/app/modules/angular-slickgrid/extensions/slickRowDetailView.d.ts +0 -2
  4. package/docs/assets/lib/multiple-select/README.md +17 -17
  5. package/esm2020/app/modules/angular-slickgrid/components/angular-slickgrid.component.mjs +14 -14
  6. package/esm2020/app/modules/angular-slickgrid/constants.mjs +1 -1
  7. package/esm2020/app/modules/angular-slickgrid/extensions/index.mjs +1 -1
  8. package/esm2020/app/modules/angular-slickgrid/extensions/slickRowDetailView.mjs +2 -4
  9. package/esm2020/app/modules/angular-slickgrid/global-grid-options.mjs +1 -1
  10. package/esm2020/app/modules/angular-slickgrid/index.mjs +1 -1
  11. package/esm2020/app/modules/angular-slickgrid/models/angularComponentOutput.interface.mjs +1 -1
  12. package/esm2020/app/modules/angular-slickgrid/models/angularGridInstance.interface.mjs +1 -1
  13. package/esm2020/app/modules/angular-slickgrid/models/externalTestingDependencies.interface.mjs +1 -1
  14. package/esm2020/app/modules/angular-slickgrid/models/gridOption.interface.mjs +1 -1
  15. package/esm2020/app/modules/angular-slickgrid/models/index.mjs +1 -1
  16. package/esm2020/app/modules/angular-slickgrid/models/rowDetailView.interface.mjs +1 -1
  17. package/esm2020/app/modules/angular-slickgrid/models/slickGrid.interface.mjs +1 -1
  18. package/esm2020/app/modules/angular-slickgrid/modules/angular-slickgrid.module.mjs +7 -10
  19. package/esm2020/app/modules/angular-slickgrid/services/angularUtil.service.mjs +4 -4
  20. package/esm2020/app/modules/angular-slickgrid/services/bsDropdown.service.mjs +4 -4
  21. package/esm2020/app/modules/angular-slickgrid/services/container.service.mjs +4 -4
  22. package/esm2020/app/modules/angular-slickgrid/services/index.mjs +1 -1
  23. package/esm2020/app/modules/angular-slickgrid/services/translater.service.mjs +4 -4
  24. package/esm2020/app/modules/angular-slickgrid/services/utilities.mjs +1 -1
  25. package/esm2020/app/modules/angular-slickgrid/slickgrid-config.mjs +1 -1
  26. package/esm2020/public_api.mjs +1 -1
  27. package/fesm2015/angular-slickgrid.mjs +32 -37
  28. package/fesm2015/angular-slickgrid.mjs.map +1 -1
  29. package/fesm2020/angular-slickgrid.mjs +32 -37
  30. package/fesm2020/angular-slickgrid.mjs.map +1 -1
  31. package/i18n/en.json +89 -89
  32. package/i18n/fr.json +90 -90
  33. package/{angular-slickgrid.d.ts → index.d.ts} +0 -0
  34. package/package.json +11 -11
  35. package/test/cypress/node_modules/@cypress/request/README.md +1038 -0
  36. package/test/cypress/node_modules/@cypress/xvfb/README.md +48 -0
  37. package/test/cypress/node_modules/@cypress/xvfb/node_modules/debug/README.md +437 -0
  38. package/test/cypress/node_modules/@types/node/README.md +16 -0
  39. package/test/cypress/node_modules/@types/sinonjs__fake-timers/README.md +16 -0
  40. package/test/cypress/node_modules/@types/sizzle/README.md +16 -0
  41. package/test/cypress/node_modules/@types/yauzl/README.md +16 -0
  42. package/test/cypress/node_modules/@types/yauzl/node_modules/@types/node/README.md +16 -0
  43. package/test/cypress/node_modules/aggregate-error/README.md +61 -0
  44. package/test/cypress/node_modules/ansi-colors/README.md +315 -0
  45. package/test/cypress/node_modules/ansi-escapes/README.md +245 -0
  46. package/test/cypress/node_modules/ansi-regex/README.md +78 -0
  47. package/test/cypress/node_modules/ansi-styles/README.md +152 -0
  48. package/test/cypress/node_modules/arch/README.md +71 -0
  49. package/test/cypress/node_modules/asn1/README.md +50 -0
  50. package/test/cypress/node_modules/assert-plus/README.md +162 -0
  51. package/test/cypress/node_modules/astral-regex/README.md +46 -0
  52. package/test/cypress/node_modules/async/README.md +60 -0
  53. package/test/cypress/node_modules/asynckit/README.md +233 -0
  54. package/test/cypress/node_modules/at-least-node/README.md +25 -0
  55. package/test/cypress/node_modules/aws-sign2/README.md +4 -0
  56. package/test/cypress/node_modules/aws4/README.md +183 -0
  57. package/test/cypress/node_modules/balanced-match/README.md +91 -0
  58. package/test/cypress/node_modules/base64-js/README.md +34 -0
  59. package/test/cypress/node_modules/bcrypt-pbkdf/README.md +45 -0
  60. package/test/cypress/node_modules/blob-util/README.md +623 -0
  61. package/test/cypress/node_modules/bluebird/README.md +57 -0
  62. package/test/cypress/node_modules/brace-expansion/README.md +129 -0
  63. package/test/cypress/node_modules/buffer/README.md +410 -0
  64. package/test/cypress/node_modules/buffer-crc32/README.md +47 -0
  65. package/test/cypress/node_modules/cachedir/README.md +27 -0
  66. package/test/cypress/node_modules/caseless/README.md +45 -0
  67. package/test/cypress/node_modules/chalk/README.md +293 -0
  68. package/test/cypress/node_modules/chalk/node_modules/supports-color/README.md +76 -0
  69. package/test/cypress/node_modules/check-more-types/README.md +952 -0
  70. package/test/cypress/node_modules/ci-info/README.md +114 -0
  71. package/test/cypress/node_modules/clean-stack/README.md +76 -0
  72. package/test/cypress/node_modules/cli-cursor/README.md +55 -0
  73. package/test/cypress/node_modules/cli-table3/README.md +218 -0
  74. package/test/cypress/node_modules/cli-truncate/README.md +139 -0
  75. package/test/cypress/node_modules/color-convert/README.md +68 -0
  76. package/test/cypress/node_modules/color-name/README.md +11 -0
  77. package/test/cypress/node_modules/colorette/README.md +102 -0
  78. package/test/cypress/node_modules/colors/README.md +221 -0
  79. package/test/cypress/node_modules/combined-stream/README.md +138 -0
  80. package/test/cypress/node_modules/commander/README.md +737 -0
  81. package/test/cypress/node_modules/common-tags/README.md +687 -0
  82. package/test/cypress/node_modules/core-util-is/README.md +3 -0
  83. package/test/cypress/node_modules/cross-spawn/README.md +96 -0
  84. package/test/cypress/node_modules/cypress/README.md +25 -0
  85. package/test/cypress/node_modules/cypress/mount-utils/README.md +14 -0
  86. package/test/cypress/node_modules/cypress/react/README.md +414 -0
  87. package/test/cypress/node_modules/cypress/vue/README.md +678 -0
  88. package/test/cypress/node_modules/cypress/vue2/README.md +693 -0
  89. package/test/cypress/node_modules/dashdash/README.md +574 -0
  90. package/test/cypress/node_modules/dayjs/README.md +128 -0
  91. package/test/cypress/node_modules/debug/README.md +455 -0
  92. package/test/cypress/node_modules/delayed-stream/README.md +141 -0
  93. package/test/cypress/node_modules/ecc-jsbn/README.md +8 -0
  94. package/test/cypress/node_modules/emoji-regex/README.md +73 -0
  95. package/test/cypress/node_modules/end-of-stream/README.md +54 -0
  96. package/test/cypress/node_modules/enquirer/README.md +1752 -0
  97. package/test/cypress/node_modules/escape-string-regexp/README.md +27 -0
  98. package/test/cypress/node_modules/eventemitter2/README.md +809 -0
  99. package/test/cypress/node_modules/execa/README.md +656 -0
  100. package/test/cypress/node_modules/executable/README.md +64 -0
  101. package/test/cypress/node_modules/extend/README.md +81 -0
  102. package/test/cypress/node_modules/extract-zip/README.md +57 -0
  103. package/test/cypress/node_modules/extract-zip/node_modules/debug/README.md +455 -0
  104. package/test/cypress/node_modules/extsprintf/README.md +46 -0
  105. package/test/cypress/node_modules/fd-slicer/README.md +199 -0
  106. package/test/cypress/node_modules/figures/README.md +139 -0
  107. package/test/cypress/node_modules/forever-agent/README.md +4 -0
  108. package/test/cypress/node_modules/form-data/README.md +234 -0
  109. package/test/cypress/node_modules/fs-extra/README.md +264 -0
  110. package/test/cypress/node_modules/fs.realpath/README.md +33 -0
  111. package/test/cypress/node_modules/get-stream/README.md +124 -0
  112. package/test/cypress/node_modules/getos/README.md +79 -0
  113. package/test/cypress/node_modules/getpass/README.md +32 -0
  114. package/test/cypress/node_modules/glob/README.md +375 -0
  115. package/test/cypress/node_modules/global-dirs/README.md +72 -0
  116. package/test/cypress/node_modules/graceful-fs/README.md +133 -0
  117. package/test/cypress/node_modules/has-flag/README.md +89 -0
  118. package/test/cypress/node_modules/http-signature/README.md +80 -0
  119. package/test/cypress/node_modules/human-signals/README.md +155 -0
  120. package/test/cypress/node_modules/ieee754/README.md +51 -0
  121. package/test/cypress/node_modules/indent-string/README.md +70 -0
  122. package/test/cypress/node_modules/inflight/README.md +37 -0
  123. package/test/cypress/node_modules/inherits/README.md +42 -0
  124. package/test/cypress/node_modules/ini/README.md +102 -0
  125. package/test/cypress/node_modules/is-ci/README.md +50 -0
  126. package/test/cypress/node_modules/is-fullwidth-code-point/README.md +39 -0
  127. package/test/cypress/node_modules/is-installed-globally/README.md +31 -0
  128. package/test/cypress/node_modules/is-path-inside/README.md +63 -0
  129. package/test/cypress/node_modules/is-stream/README.md +57 -0
  130. package/test/cypress/node_modules/is-typedarray/README.md +16 -0
  131. package/test/cypress/node_modules/isexe/README.md +51 -0
  132. package/test/cypress/node_modules/isstream/README.md +66 -0
  133. package/test/cypress/node_modules/jsbn/README.md +175 -0
  134. package/test/cypress/node_modules/json-schema/README.md +3 -0
  135. package/test/cypress/node_modules/json-stringify-safe/README.md +52 -0
  136. package/test/cypress/node_modules/jsonfile/README.md +205 -0
  137. package/test/cypress/node_modules/jsonfile/node_modules/universalify/README.md +76 -0
  138. package/test/cypress/node_modules/jsprim/README.md +287 -0
  139. package/test/cypress/node_modules/lazy-ass/README.md +269 -0
  140. package/test/cypress/node_modules/listr2/README.md +17 -0
  141. package/test/cypress/node_modules/lodash/README.md +39 -0
  142. package/test/cypress/node_modules/lodash.once/README.md +18 -0
  143. package/test/cypress/node_modules/log-symbols/README.md +51 -0
  144. package/test/cypress/node_modules/log-update/README.md +97 -0
  145. package/test/cypress/node_modules/log-update/node_modules/slice-ansi/README.md +66 -0
  146. package/test/cypress/node_modules/log-update/node_modules/wrap-ansi/README.md +97 -0
  147. package/test/cypress/node_modules/lru-cache/README.md +166 -0
  148. package/test/cypress/node_modules/merge-stream/README.md +78 -0
  149. package/test/cypress/node_modules/mime-db/README.md +102 -0
  150. package/test/cypress/node_modules/mime-types/README.md +123 -0
  151. package/test/cypress/node_modules/mimic-fn/README.md +69 -0
  152. package/test/cypress/node_modules/minimatch/README.md +209 -0
  153. package/test/cypress/node_modules/ms/README.md +60 -0
  154. package/test/cypress/node_modules/npm-run-path/README.md +115 -0
  155. package/test/cypress/node_modules/once/README.md +79 -0
  156. package/test/cypress/node_modules/onetime/README.md +94 -0
  157. package/test/cypress/node_modules/ospath/README.md +53 -0
  158. package/test/cypress/node_modules/p-map/README.md +89 -0
  159. package/test/cypress/node_modules/path-is-absolute/README.md +59 -0
  160. package/test/cypress/node_modules/path-key/README.md +61 -0
  161. package/test/cypress/node_modules/pend/README.md +41 -0
  162. package/test/cypress/node_modules/performance-now/README.md +30 -0
  163. package/test/cypress/node_modules/pify/README.md +119 -0
  164. package/test/cypress/node_modules/pretty-bytes/README.md +131 -0
  165. package/test/cypress/node_modules/proxy-from-env/README.md +131 -0
  166. package/test/cypress/node_modules/psl/README.md +215 -0
  167. package/test/cypress/node_modules/pump/README.md +65 -0
  168. package/test/cypress/node_modules/punycode/README.md +122 -0
  169. package/test/cypress/node_modules/qs/README.md +475 -0
  170. package/test/cypress/node_modules/request-progress/README.md +78 -0
  171. package/test/cypress/node_modules/restore-cursor/README.md +26 -0
  172. package/test/cypress/node_modules/rimraf/README.md +101 -0
  173. package/test/cypress/node_modules/rxjs/README.md +147 -0
  174. package/test/cypress/node_modules/rxjs/_esm2015/README.md +147 -0
  175. package/test/cypress/node_modules/rxjs/_esm5/README.md +147 -0
  176. package/test/cypress/node_modules/rxjs/src/README.md +147 -0
  177. package/test/cypress/node_modules/safe-buffer/README.md +584 -0
  178. package/test/cypress/node_modules/safer-buffer/README.md +156 -0
  179. package/test/cypress/node_modules/semver/README.md +566 -0
  180. package/test/cypress/node_modules/shebang-command/README.md +34 -0
  181. package/test/cypress/node_modules/shebang-regex/README.md +33 -0
  182. package/test/cypress/node_modules/signal-exit/README.md +39 -0
  183. package/test/cypress/node_modules/slice-ansi/README.md +72 -0
  184. package/test/cypress/node_modules/sshpk/README.md +804 -0
  185. package/test/cypress/node_modules/string-width/README.md +50 -0
  186. package/test/cypress/node_modules/strip-ansi/README.md +46 -0
  187. package/test/cypress/node_modules/strip-final-newline/README.md +30 -0
  188. package/test/cypress/node_modules/supports-color/README.md +77 -0
  189. package/test/cypress/node_modules/throttleit/README.md +32 -0
  190. package/test/cypress/node_modules/tmp/README.md +365 -0
  191. package/test/cypress/node_modules/tough-cookie/README.md +527 -0
  192. package/test/cypress/node_modules/tslib/README.md +142 -0
  193. package/test/cypress/node_modules/tunnel-agent/README.md +4 -0
  194. package/test/cypress/node_modules/tweetnacl/README.md +459 -0
  195. package/test/cypress/node_modules/type-fest/README.md +760 -0
  196. package/test/cypress/node_modules/universalify/README.md +76 -0
  197. package/test/cypress/node_modules/untildify/README.md +30 -0
  198. package/test/cypress/node_modules/uuid/README.md +505 -0
  199. package/test/cypress/node_modules/verror/README.md +528 -0
  200. package/test/cypress/node_modules/verror/node_modules/extsprintf/README.md +46 -0
  201. package/test/cypress/node_modules/which/README.md +54 -0
  202. package/test/cypress/node_modules/wrap-ansi/README.md +91 -0
  203. package/test/cypress/node_modules/wrappy/README.md +36 -0
  204. package/test/cypress/node_modules/yallist/README.md +204 -0
  205. package/test/cypress/node_modules/yauzl/README.md +658 -0
@@ -0,0 +1,737 @@
1
+ # Commander.js
2
+
3
+ [![Build Status](https://api.travis-ci.org/tj/commander.js.svg?branch=master)](http://travis-ci.org/tj/commander.js)
4
+ [![NPM Version](http://img.shields.io/npm/v/commander.svg?style=flat)](https://www.npmjs.org/package/commander)
5
+ [![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://npmcharts.com/compare/commander?minimal=true)
6
+ [![Install Size](https://packagephobia.now.sh/badge?p=commander)](https://packagephobia.now.sh/result?p=commander)
7
+
8
+ The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/commander-rb/commander).
9
+
10
+ Read this in other languages: English | [简体中文](./Readme_zh-CN.md)
11
+
12
+ - [Commander.js](#commanderjs)
13
+ - [Installation](#installation)
14
+ - [Declaring _program_ variable](#declaring-program-variable)
15
+ - [Options](#options)
16
+ - [Common option types, boolean and value](#common-option-types-boolean-and-value)
17
+ - [Default option value](#default-option-value)
18
+ - [Other option types, negatable boolean and flag|value](#other-option-types-negatable-boolean-and-flagvalue)
19
+ - [Custom option processing](#custom-option-processing)
20
+ - [Required option](#required-option)
21
+ - [Version option](#version-option)
22
+ - [Commands](#commands)
23
+ - [Specify the argument syntax](#specify-the-argument-syntax)
24
+ - [Action handler (sub)commands](#action-handler-subcommands)
25
+ - [Stand-alone executable (sub)commands](#stand-alone-executable-subcommands)
26
+ - [Automated help](#automated-help)
27
+ - [Custom help](#custom-help)
28
+ - [.usage and .name](#usage-and-name)
29
+ - [.help(cb)](#helpcb)
30
+ - [.outputHelp(cb)](#outputhelpcb)
31
+ - [.helpInformation()](#helpinformation)
32
+ - [.helpOption(flags, description)](#helpoptionflags-description)
33
+ - [.addHelpCommand()](#addhelpcommand)
34
+ - [Custom event listeners](#custom-event-listeners)
35
+ - [Bits and pieces](#bits-and-pieces)
36
+ - [.parse() and .parseAsync()](#parse-and-parseasync)
37
+ - [Avoiding option name clashes](#avoiding-option-name-clashes)
38
+ - [TypeScript](#typescript)
39
+ - [createCommand()](#createcommand)
40
+ - [Node options such as `--harmony`](#node-options-such-as---harmony)
41
+ - [Debugging stand-alone executable subcommands](#debugging-stand-alone-executable-subcommands)
42
+ - [Override exit handling](#override-exit-handling)
43
+ - [Examples](#examples)
44
+ - [License](#license)
45
+ - [Support](#support)
46
+ - [Commander for enterprise](#commander-for-enterprise)
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ npm install commander
52
+ ```
53
+
54
+ ## Declaring _program_ variable
55
+
56
+ Commander exports a global object which is convenient for quick programs.
57
+ This is used in the examples in this README for brevity.
58
+
59
+ ```js
60
+ const { program } = require('commander');
61
+ program.version('0.0.1');
62
+ ```
63
+
64
+ For larger programs which may use commander in multiple ways, including unit testing, it is better to create a local Command object to use.
65
+
66
+ ```js
67
+ const { Command } = require('commander');
68
+ const program = new Command();
69
+ program.version('0.0.1');
70
+ ```
71
+
72
+ ## Options
73
+
74
+ Options are defined with the `.option()` method, also serving as documentation for the options. Each option can have a short flag (single character) and a long name, separated by a comma or space or vertical bar ('|').
75
+
76
+ The options can be accessed as properties on the Command object. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc. See also optional new behaviour to [avoid name clashes](#avoiding-option-name-clashes).
77
+
78
+ Multiple short flags may optionally be combined in a single argument following the dash: boolean flags, the last flag may take a value, and the value.
79
+ For example `-a -b -p 80` may be written as `-ab -p80` or even `-abp80`.
80
+
81
+ You can use `--` to indicate the end of the options, and any remaining arguments will be used without being interpreted.
82
+ This is particularly useful for passing options through to another
83
+ command, like: `do -- git --version`.
84
+
85
+ Options on the command line are not positional, and can be specified before or after other command arguments.
86
+
87
+ ### Common option types, boolean and value
88
+
89
+ The two most used option types are a boolean flag, and an option which takes a value (declared using angle brackets). Both are `undefined` unless specified on command line.
90
+
91
+ ```js
92
+ const { program } = require('commander');
93
+
94
+ program
95
+ .option('-d, --debug', 'output extra debugging')
96
+ .option('-s, --small', 'small pizza size')
97
+ .option('-p, --pizza-type <type>', 'flavour of pizza');
98
+
99
+ program.parse(process.argv);
100
+
101
+ if (program.debug) console.log(program.opts());
102
+ console.log('pizza details:');
103
+ if (program.small) console.log('- small pizza size');
104
+ if (program.pizzaType) console.log(`- ${program.pizzaType}`);
105
+ ```
106
+
107
+ ```bash
108
+ $ pizza-options -d
109
+ { debug: true, small: undefined, pizzaType: undefined }
110
+ pizza details:
111
+ $ pizza-options -p
112
+ error: option '-p, --pizza-type <type>' argument missing
113
+ $ pizza-options -ds -p vegetarian
114
+ { debug: true, small: true, pizzaType: 'vegetarian' }
115
+ pizza details:
116
+ - small pizza size
117
+ - vegetarian
118
+ $ pizza-options --pizza-type=cheese
119
+ pizza details:
120
+ - cheese
121
+ ```
122
+
123
+ `program.parse(arguments)` processes the arguments, leaving any args not consumed by the program options in the `program.args` array.
124
+
125
+ ### Default option value
126
+
127
+ You can specify a default value for an option which takes a value.
128
+
129
+ ```js
130
+ const { program } = require('commander');
131
+
132
+ program
133
+ .option('-c, --cheese <type>', 'add the specified type of cheese', 'blue');
134
+
135
+ program.parse(process.argv);
136
+
137
+ console.log(`cheese: ${program.cheese}`);
138
+ ```
139
+
140
+ ```bash
141
+ $ pizza-options
142
+ cheese: blue
143
+ $ pizza-options --cheese stilton
144
+ cheese: stilton
145
+ ```
146
+
147
+ ### Other option types, negatable boolean and flag|value
148
+
149
+ You can specify a boolean option long name with a leading `no-` to set the option value to false when used.
150
+ Defined alone this also makes the option true by default.
151
+
152
+ If you define `--foo` first, adding `--no-foo` does not change the default value from what it would
153
+ otherwise be. You can specify a default boolean value for a boolean flag and it can be overridden on command line.
154
+
155
+ ```js
156
+ const { program } = require('commander');
157
+
158
+ program
159
+ .option('--no-sauce', 'Remove sauce')
160
+ .option('--cheese <flavour>', 'cheese flavour', 'mozzarella')
161
+ .option('--no-cheese', 'plain with no cheese')
162
+ .parse(process.argv);
163
+
164
+ const sauceStr = program.sauce ? 'sauce' : 'no sauce';
165
+ const cheeseStr = (program.cheese === false) ? 'no cheese' : `${program.cheese} cheese`;
166
+ console.log(`You ordered a pizza with ${sauceStr} and ${cheeseStr}`);
167
+ ```
168
+
169
+ ```bash
170
+ $ pizza-options
171
+ You ordered a pizza with sauce and mozzarella cheese
172
+ $ pizza-options --sauce
173
+ error: unknown option '--sauce'
174
+ $ pizza-options --cheese=blue
175
+ You ordered a pizza with sauce and blue cheese
176
+ $ pizza-options --no-sauce --no-cheese
177
+ You ordered a pizza with no sauce and no cheese
178
+ ```
179
+
180
+ You can specify an option which functions as a flag but may also take a value (declared using square brackets).
181
+
182
+ ```js
183
+ const { program } = require('commander');
184
+
185
+ program
186
+ .option('-c, --cheese [type]', 'Add cheese with optional type');
187
+
188
+ program.parse(process.argv);
189
+
190
+ if (program.cheese === undefined) console.log('no cheese');
191
+ else if (program.cheese === true) console.log('add cheese');
192
+ else console.log(`add cheese type ${program.cheese}`);
193
+ ```
194
+
195
+ ```bash
196
+ $ pizza-options
197
+ no cheese
198
+ $ pizza-options --cheese
199
+ add cheese
200
+ $ pizza-options --cheese mozzarella
201
+ add cheese type mozzarella
202
+ ```
203
+
204
+ ### Custom option processing
205
+
206
+ You may specify a function to do custom processing of option values. The callback function receives two parameters, the user specified value and the
207
+ previous value for the option. It returns the new value for the option.
208
+
209
+ This allows you to coerce the option value to the desired type, or accumulate values, or do entirely custom processing.
210
+
211
+ You can optionally specify the default/starting value for the option after the function.
212
+
213
+ ```js
214
+ const { program } = require('commander');
215
+
216
+ function myParseInt(value, dummyPrevious) {
217
+ // parseInt takes a string and an optional radix
218
+ return parseInt(value);
219
+ }
220
+
221
+ function increaseVerbosity(dummyValue, previous) {
222
+ return previous + 1;
223
+ }
224
+
225
+ function collect(value, previous) {
226
+ return previous.concat([value]);
227
+ }
228
+
229
+ function commaSeparatedList(value, dummyPrevious) {
230
+ return value.split(',');
231
+ }
232
+
233
+ program
234
+ .option('-f, --float <number>', 'float argument', parseFloat)
235
+ .option('-i, --integer <number>', 'integer argument', myParseInt)
236
+ .option('-v, --verbose', 'verbosity that can be increased', increaseVerbosity, 0)
237
+ .option('-c, --collect <value>', 'repeatable value', collect, [])
238
+ .option('-l, --list <items>', 'comma separated list', commaSeparatedList)
239
+ ;
240
+
241
+ program.parse(process.argv);
242
+
243
+ if (program.float !== undefined) console.log(`float: ${program.float}`);
244
+ if (program.integer !== undefined) console.log(`integer: ${program.integer}`);
245
+ if (program.verbose > 0) console.log(`verbosity: ${program.verbose}`);
246
+ if (program.collect.length > 0) console.log(program.collect);
247
+ if (program.list !== undefined) console.log(program.list);
248
+ ```
249
+
250
+ ```bash
251
+ $ custom -f 1e2
252
+ float: 100
253
+ $ custom --integer 2
254
+ integer: 2
255
+ $ custom -v -v -v
256
+ verbose: 3
257
+ $ custom -c a -c b -c c
258
+ [ 'a', 'b', 'c' ]
259
+ $ custom --list x,y,z
260
+ [ 'x', 'y', 'z' ]
261
+ ```
262
+
263
+ ### Required option
264
+
265
+ You may specify a required (mandatory) option using `.requiredOption`. The option must have a value after parsing, usually specified on the command line, or perhaps from a default value (say from environment). The method is otherwise the same as `.option` in format, taking flags and description, and optional default value or custom processing.
266
+
267
+ ```js
268
+ const { program } = require('commander');
269
+
270
+ program
271
+ .requiredOption('-c, --cheese <type>', 'pizza must have cheese');
272
+
273
+ program.parse(process.argv);
274
+ ```
275
+
276
+ ```bash
277
+ $ pizza
278
+ error: required option '-c, --cheese <type>' not specified
279
+ ```
280
+
281
+ ### Version option
282
+
283
+ The optional `version` method adds handling for displaying the command version. The default option flags are `-V` and `--version`, and when present the command prints the version number and exits.
284
+
285
+ ```js
286
+ program.version('0.0.1');
287
+ ```
288
+
289
+ ```bash
290
+ $ ./examples/pizza -V
291
+ 0.0.1
292
+ ```
293
+
294
+ You may change the flags and description by passing additional parameters to the `version` method, using
295
+ the same syntax for flags as the `option` method. The version flags can be named anything, but a long name is required.
296
+
297
+ ```js
298
+ program.version('0.0.1', '-v, --vers', 'output the current version');
299
+ ```
300
+
301
+ ## Commands
302
+
303
+ You can specify (sub)commands using `.command()` or `.addCommand()`. There are two ways these can be implemented: using an action handler attached to the command, or as a stand-alone executable file (described in more detail later). The subcommands may be nested ([example](./examples/nestedCommands.js)).
304
+
305
+ In the first parameter to `.command()` you specify the command name and any command arguments. The arguments may be `<required>` or `[optional]`, and the last argument may also be `variadic...`.
306
+
307
+ You can use `.addCommand()` to add an already configured subcommand to the program.
308
+
309
+ For example:
310
+
311
+ ```js
312
+ // Command implemented using action handler (description is supplied separately to `.command`)
313
+ // Returns new command for configuring.
314
+ program
315
+ .command('clone <source> [destination]')
316
+ .description('clone a repository into a newly created directory')
317
+ .action((source, destination) => {
318
+ console.log('clone command called');
319
+ });
320
+
321
+ // Command implemented using stand-alone executable file (description is second parameter to `.command`)
322
+ // Returns `this` for adding more commands.
323
+ program
324
+ .command('start <service>', 'start named service')
325
+ .command('stop [service]', 'stop named service, or all if no name supplied');
326
+
327
+ // Command prepared separately.
328
+ // Returns `this` for adding more commands.
329
+ program
330
+ .addCommand(build.makeBuildCommand());
331
+ ```
332
+
333
+ Configuration options can be passed with the call to `.command()` and `.addCommand()`. Specifying `true` for `opts.hidden` will remove the command from the generated help output. Specifying `true` for `opts.isDefault` will run the subcommand if no other subcommand is specified ([example](./examples/defaultCommand.js)).
334
+
335
+ ### Specify the argument syntax
336
+
337
+ You use `.arguments` to specify the arguments for the top-level command, and for subcommands they are usually included in the `.command` call. Angled brackets (e.g. `<required>`) indicate required input. Square brackets (e.g. `[optional]`) indicate optional input.
338
+
339
+ ```js
340
+ const { program } = require('commander');
341
+
342
+ program
343
+ .version('0.1.0')
344
+ .arguments('<cmd> [env]')
345
+ .action(function (cmd, env) {
346
+ cmdValue = cmd;
347
+ envValue = env;
348
+ });
349
+
350
+ program.parse(process.argv);
351
+
352
+ if (typeof cmdValue === 'undefined') {
353
+ console.error('no command given!');
354
+ process.exit(1);
355
+ }
356
+ console.log('command:', cmdValue);
357
+ console.log('environment:', envValue || "no environment given");
358
+ ```
359
+
360
+ The last argument of a command can be variadic, and only the last argument. To make an argument variadic you
361
+ append `...` to the argument name. For example:
362
+
363
+ ```js
364
+ const { program } = require('commander');
365
+
366
+ program
367
+ .version('0.1.0')
368
+ .command('rmdir <dir> [otherDirs...]')
369
+ .action(function (dir, otherDirs) {
370
+ console.log('rmdir %s', dir);
371
+ if (otherDirs) {
372
+ otherDirs.forEach(function (oDir) {
373
+ console.log('rmdir %s', oDir);
374
+ });
375
+ }
376
+ });
377
+
378
+ program.parse(process.argv);
379
+ ```
380
+
381
+ The variadic argument is passed to the action handler as an array.
382
+
383
+ ### Action handler (sub)commands
384
+
385
+ You can add options to a command that uses an action handler.
386
+ The action handler gets passed a parameter for each argument you declared, and one additional argument which is the
387
+ command object itself. This command argument has the values for the command-specific options added as properties.
388
+
389
+ ```js
390
+ const { program } = require('commander');
391
+
392
+ program
393
+ .command('rm <dir>')
394
+ .option('-r, --recursive', 'Remove recursively')
395
+ .action(function (dir, cmdObj) {
396
+ console.log('remove ' + dir + (cmdObj.recursive ? ' recursively' : ''))
397
+ })
398
+
399
+ program.parse(process.argv)
400
+ ```
401
+
402
+ You may supply an `async` action handler, in which case you call `.parseAsync` rather than `.parse`.
403
+
404
+ ```js
405
+ async function run() { /* code goes here */ }
406
+
407
+ async function main() {
408
+ program
409
+ .command('run')
410
+ .action(run);
411
+ await program.parseAsync(process.argv);
412
+ }
413
+ ```
414
+
415
+ A command's options on the command line are validated when the command is used. Any unknown options will be reported as an error.
416
+
417
+ ### Stand-alone executable (sub)commands
418
+
419
+ When `.command()` is invoked with a description argument, this tells Commander that you're going to use stand-alone executables for subcommands.
420
+ Commander will search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-subcommand`, like `pm-install`, `pm-search`.
421
+ You can specify a custom name with the `executableFile` configuration option.
422
+
423
+ You handle the options for an executable (sub)command in the executable, and don't declare them at the top-level.
424
+
425
+ ```js
426
+ // file: ./examples/pm
427
+ const { program } = require('commander');
428
+
429
+ program
430
+ .version('0.1.0')
431
+ .command('install [name]', 'install one or more packages')
432
+ .command('search [query]', 'search with optional query')
433
+ .command('update', 'update installed packages', {executableFile: 'myUpdateSubCommand'})
434
+ .command('list', 'list packages installed', {isDefault: true})
435
+ .parse(process.argv);
436
+ ```
437
+
438
+ If the program is designed to be installed globally, make sure the executables have proper modes, like `755`.
439
+
440
+ ## Automated help
441
+
442
+ The help information is auto-generated based on the information commander already knows about your program. The default
443
+ help option is `-h,--help`. ([example](./examples/pizza))
444
+
445
+ ```bash
446
+ $ node ./examples/pizza --help
447
+ Usage: pizza [options]
448
+
449
+ An application for pizzas ordering
450
+
451
+ Options:
452
+ -V, --version output the version number
453
+ -p, --peppers Add peppers
454
+ -c, --cheese <type> Add the specified type of cheese (default: "marble")
455
+ -C, --no-cheese You do not want any cheese
456
+ -h, --help display help for command
457
+ ```
458
+
459
+ A `help` command is added by default if your command has subcommands. It can be used alone, or with a subcommand name to show
460
+ further help for the subcommand. These are effectively the same if the `shell` program has implicit help:
461
+
462
+ ```bash
463
+ shell help
464
+ shell --help
465
+
466
+ shell help spawn
467
+ shell spawn --help
468
+ ```
469
+
470
+ ### Custom help
471
+
472
+ You can display extra information by listening for "--help". ([example](./examples/custom-help))
473
+
474
+ ```js
475
+ program
476
+ .option('-f, --foo', 'enable some foo');
477
+
478
+ // must be before .parse()
479
+ program.on('--help', () => {
480
+ console.log('');
481
+ console.log('Example call:');
482
+ console.log(' $ custom-help --help');
483
+ });
484
+ ```
485
+
486
+ Yields the following help output:
487
+
488
+ ```Text
489
+ Usage: custom-help [options]
490
+
491
+ Options:
492
+ -f, --foo enable some foo
493
+ -h, --help display help for command
494
+
495
+ Example call:
496
+ $ custom-help --help
497
+ ```
498
+
499
+ ### .usage and .name
500
+
501
+ These allow you to customise the usage description in the first line of the help. The name is otherwise
502
+ deduced from the (full) program arguments. Given:
503
+
504
+ ```js
505
+ program
506
+ .name("my-command")
507
+ .usage("[global options] command")
508
+ ```
509
+
510
+ The help will start with:
511
+
512
+ ```Text
513
+ Usage: my-command [global options] command
514
+ ```
515
+
516
+ ### .help(cb)
517
+
518
+ Output help information and exit immediately. Optional callback cb allows post-processing of help text before it is displayed.
519
+
520
+ ### .outputHelp(cb)
521
+
522
+ Output help information without exiting.
523
+ Optional callback cb allows post-processing of help text before it is displayed.
524
+
525
+ ### .helpInformation()
526
+
527
+ Get the command help information as a string for processing or displaying yourself. (The text does not include the custom help
528
+ from `--help` listeners.)
529
+
530
+ ### .helpOption(flags, description)
531
+
532
+ Override the default help flags and description.
533
+
534
+ ```js
535
+ program
536
+ .helpOption('-e, --HELP', 'read more information');
537
+ ```
538
+
539
+ ### .addHelpCommand()
540
+
541
+ You can explicitly turn on or off the implicit help command with `.addHelpCommand()` and `.addHelpCommand(false)`.
542
+
543
+ You can both turn on and customise the help command by supplying the name and description:
544
+
545
+ ```js
546
+ program.addHelpCommand('assist [command]', 'show assistance');
547
+ ```
548
+
549
+ ## Custom event listeners
550
+
551
+ You can execute custom actions by listening to command and option events.
552
+
553
+ ```js
554
+ program.on('option:verbose', function () {
555
+ process.env.VERBOSE = this.verbose;
556
+ });
557
+
558
+ program.on('command:*', function (operands) {
559
+ console.error(`error: unknown command '${operands[0]}'`);
560
+ const availableCommands = program.commands.map(cmd => cmd.name());
561
+ mySuggestBestMatch(operands[0], availableCommands);
562
+ process.exitCode = 1;
563
+ });
564
+ ```
565
+
566
+ ## Bits and pieces
567
+
568
+ ### .parse() and .parseAsync()
569
+
570
+ The first argument to `.parse` is the array of strings to parse. You may omit the parameter to implicitly use `process.argv`.
571
+
572
+ If the arguments follow different conventions than node you can pass a `from` option in the second parameter:
573
+
574
+ - 'node': default, `argv[0]` is the application and `argv[1]` is the script being run, with user parameters after that
575
+ - 'electron': `argv[1]` varies depending on whether the electron application is packaged
576
+ - 'user': all of the arguments from the user
577
+
578
+ For example:
579
+
580
+ ```js
581
+ program.parse(process.argv); // Explicit, node conventions
582
+ program.parse(); // Implicit, and auto-detect electron
583
+ program.parse(['-f', 'filename'], { from: 'user' });
584
+ ```
585
+
586
+ ### Avoiding option name clashes
587
+
588
+ The original and default behaviour is that the option values are stored
589
+ as properties on the program, and the action handler is passed a
590
+ command object with the options values stored as properties.
591
+ This is very convenient to code, but the downside is possible clashes with
592
+ existing properties of Command.
593
+
594
+ There are two new routines to change the behaviour, and the default behaviour may change in the future:
595
+
596
+ - `storeOptionsAsProperties`: whether to store option values as properties on command object, or store separately (specify false) and access using `.opts()`
597
+ - `passCommandToAction`: whether to pass command to action handler,
598
+ or just the options (specify false)
599
+
600
+ ([example](./examples/storeOptionsAsProperties-action.js))
601
+
602
+ ```js
603
+ program
604
+ .storeOptionsAsProperties(false)
605
+ .passCommandToAction(false);
606
+
607
+ program
608
+ .name('my-program-name')
609
+ .option('-n,--name <name>');
610
+
611
+ program
612
+ .command('show')
613
+ .option('-a,--action <action>')
614
+ .action((options) => {
615
+ console.log(options.action);
616
+ });
617
+
618
+ program.parse(process.argv);
619
+
620
+ const programOptions = program.opts();
621
+ console.log(programOptions.name);
622
+ ```
623
+
624
+ ### TypeScript
625
+
626
+ The Commander package includes its TypeScript Definition file.
627
+
628
+ If you use `ts-node` and stand-alone executable subcommands written as `.ts` files, you need to call your program through node to get the subcommands called correctly. e.g.
629
+
630
+ ```bash
631
+ node -r ts-node/register pm.ts
632
+ ```
633
+
634
+ ### createCommand()
635
+
636
+ This factory function creates a new command. It is exported and may be used instead of using `new`, like:
637
+
638
+ ```js
639
+ const { createCommand } = require('commander');
640
+ const program = createCommand();
641
+ ```
642
+
643
+ `createCommand` is also a method of the Command object, and creates a new command rather than a subcommand. This gets used internally
644
+ when creating subcommands using `.command()`, and you may override it to
645
+ customise the new subcommand (examples using [subclass](./examples/custom-command-class.js) and [function](./examples/custom-command-function.js)).
646
+
647
+ ### Node options such as `--harmony`
648
+
649
+ You can enable `--harmony` option in two ways:
650
+
651
+ - Use `#! /usr/bin/env node --harmony` in the subcommands scripts. (Note Windows does not support this pattern.)
652
+ - Use the `--harmony` option when call the command, like `node --harmony examples/pm publish`. The `--harmony` option will be preserved when spawning subcommand process.
653
+
654
+ ### Debugging stand-alone executable subcommands
655
+
656
+ An executable subcommand is launched as a separate child process.
657
+
658
+ If you are using the node inspector for [debugging](https://nodejs.org/en/docs/guides/debugging-getting-started/) executable subcommands using `node --inspect` et al,
659
+ the inspector port is incremented by 1 for the spawned subcommand.
660
+
661
+ If you are using VSCode to debug executable subcommands you need to set the `"autoAttachChildProcesses": true` flag in your launch.json configuration.
662
+
663
+ ### Override exit handling
664
+
665
+ By default Commander calls `process.exit` when it detects errors, or after displaying the help or version. You can override
666
+ this behaviour and optionally supply a callback. The default override throws a `CommanderError`.
667
+
668
+ The override callback is passed a `CommanderError` with properties `exitCode` number, `code` string, and `message`. The default override behaviour is to throw the error, except for async handling of executable subcommand completion which carries on. The normal display of error messages or version or help
669
+ is not affected by the override which is called after the display.
670
+
671
+ ``` js
672
+ program.exitOverride();
673
+
674
+ try {
675
+ program.parse(process.argv);
676
+ } catch (err) {
677
+ // custom processing...
678
+ }
679
+ ```
680
+
681
+ ## Examples
682
+
683
+ ```js
684
+ const { program } = require('commander');
685
+
686
+ program
687
+ .version('0.1.0')
688
+ .option('-C, --chdir <path>', 'change the working directory')
689
+ .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
690
+ .option('-T, --no-tests', 'ignore test hook');
691
+
692
+ program
693
+ .command('setup [env]')
694
+ .description('run setup commands for all envs')
695
+ .option("-s, --setup_mode [mode]", "Which setup mode to use")
696
+ .action(function(env, options){
697
+ const mode = options.setup_mode || "normal";
698
+ env = env || 'all';
699
+ console.log('setup for %s env(s) with %s mode', env, mode);
700
+ });
701
+
702
+ program
703
+ .command('exec <cmd>')
704
+ .alias('ex')
705
+ .description('execute the given remote cmd')
706
+ .option("-e, --exec_mode <mode>", "Which exec mode to use")
707
+ .action(function(cmd, options){
708
+ console.log('exec "%s" using %s mode', cmd, options.exec_mode);
709
+ }).on('--help', function() {
710
+ console.log('');
711
+ console.log('Examples:');
712
+ console.log('');
713
+ console.log(' $ deploy exec sequential');
714
+ console.log(' $ deploy exec async');
715
+ });
716
+
717
+ program.parse(process.argv);
718
+ ```
719
+
720
+ More Demos can be found in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory.
721
+
722
+ ## License
723
+
724
+ [MIT](https://github.com/tj/commander.js/blob/master/LICENSE)
725
+
726
+ ## Support
727
+
728
+ Commander 5.x is fully supported on Long Term Support versions of Node, and is likely to work with Node 6 but not tested.
729
+ (For versions of Node below Node 6, use Commander 3.x or 2.x.)
730
+
731
+ The main forum for free and community support is the project [Issues](https://github.com/tj/commander.js/issues) on GitHub.
732
+
733
+ ### Commander for enterprise
734
+
735
+ Available as part of the Tidelift Subscription
736
+
737
+ The maintainers of Commander and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-commander?utm_source=npm-commander&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)