@emulsify/cli 1.6.0 → 1.7.1
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.
- package/README.md +89 -1
- package/dist/handlers/componentInstall.js +1 -1
- package/dist/handlers/componentList.js +1 -1
- package/dist/handlers/systemInstall.js +24 -9
- package/dist/index.js +12 -21
- package/dist/node_modules/.package-lock.json +24 -24
- package/dist/node_modules/@types/node/LICENSE +0 -0
- package/dist/node_modules/@types/node/README.md +1 -1
- package/dist/node_modules/@types/node/assert.d.ts +33 -31
- package/dist/node_modules/@types/node/async_hooks.d.ts +28 -20
- package/dist/node_modules/@types/node/buffer.d.ts +4 -4
- package/dist/node_modules/@types/node/child_process.d.ts +230 -62
- package/dist/node_modules/@types/node/cluster.d.ts +62 -27
- package/dist/node_modules/@types/node/console.d.ts +6 -6
- package/dist/node_modules/@types/node/constants.d.ts +12 -11
- package/dist/node_modules/@types/node/crypto.d.ts +311 -237
- package/dist/node_modules/@types/node/dgram.d.ts +50 -14
- package/dist/node_modules/@types/node/dns.d.ts +183 -54
- package/dist/node_modules/@types/node/domain.d.ts +4 -4
- package/dist/node_modules/@types/node/events.d.ts +4 -4
- package/dist/node_modules/@types/node/fs/promises.d.ts +105 -39
- package/dist/node_modules/@types/node/fs.d.ts +440 -126
- package/dist/node_modules/@types/node/globals.d.ts +41 -22
- package/dist/node_modules/@types/node/globals.global.d.ts +0 -0
- package/dist/node_modules/@types/node/http.d.ts +306 -217
- package/dist/node_modules/@types/node/http2.d.ts +341 -95
- package/dist/node_modules/@types/node/https.d.ts +250 -118
- package/dist/node_modules/@types/node/index.d.ts +1 -1
- package/dist/node_modules/@types/node/inspector.d.ts +1 -2
- package/dist/node_modules/@types/node/module.d.ts +4 -4
- package/dist/node_modules/@types/node/net.d.ts +28 -12
- package/dist/node_modules/@types/node/os.d.ts +5 -4
- package/dist/node_modules/@types/node/package.json +10 -3
- package/dist/node_modules/@types/node/path.d.ts +35 -24
- package/dist/node_modules/@types/node/perf_hooks.d.ts +5 -5
- package/dist/node_modules/@types/node/process.d.ts +61 -22
- package/dist/node_modules/@types/node/punycode.d.ts +3 -3
- package/dist/node_modules/@types/node/querystring.d.ts +15 -5
- package/dist/node_modules/@types/node/readline.d.ts +16 -6
- package/dist/node_modules/@types/node/repl.d.ts +13 -7
- package/dist/node_modules/@types/node/stream.d.ts +182 -23
- package/dist/node_modules/@types/node/string_decoder.d.ts +3 -3
- package/dist/node_modules/@types/node/timers.d.ts +5 -5
- package/dist/node_modules/@types/node/tls.d.ts +112 -30
- package/dist/node_modules/@types/node/trace_events.d.ts +3 -3
- package/dist/node_modules/@types/node/ts4.8/assert.d.ts +130 -0
- package/dist/node_modules/@types/node/ts4.8/async_hooks.d.ts +237 -0
- package/dist/node_modules/@types/node/ts4.8/buffer.d.ts +89 -0
- package/dist/node_modules/@types/node/ts4.8/child_process.d.ts +682 -0
- package/dist/node_modules/@types/node/ts4.8/cluster.d.ts +300 -0
- package/dist/node_modules/@types/node/ts4.8/console.d.ts +142 -0
- package/dist/node_modules/@types/node/ts4.8/constants.d.ts +19 -0
- package/dist/node_modules/@types/node/ts4.8/crypto.d.ts +1287 -0
- package/dist/node_modules/@types/node/ts4.8/dgram.d.ts +180 -0
- package/dist/node_modules/@types/node/ts4.8/dns.d.ts +516 -0
- package/dist/node_modules/@types/node/ts4.8/domain.d.ts +27 -0
- package/dist/node_modules/@types/node/ts4.8/events.d.ts +82 -0
- package/dist/node_modules/@types/node/ts4.8/fs/promises.d.ts +634 -0
- package/dist/node_modules/@types/node/ts4.8/fs.d.ts +2587 -0
- package/dist/node_modules/@types/node/ts4.8/globals.d.ts +763 -0
- package/dist/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
- package/dist/node_modules/@types/node/ts4.8/http.d.ts +580 -0
- package/dist/node_modules/@types/node/ts4.8/http2.d.ts +1208 -0
- package/dist/node_modules/@types/node/ts4.8/https.d.ts +274 -0
- package/dist/node_modules/@types/node/ts4.8/index.d.ts +53 -0
- package/dist/node_modules/@types/node/ts4.8/inspector.d.ts +3050 -0
- package/dist/node_modules/@types/node/ts4.8/module.d.ts +56 -0
- package/dist/node_modules/@types/node/ts4.8/net.d.ts +324 -0
- package/dist/node_modules/@types/node/ts4.8/os.d.ts +243 -0
- package/dist/node_modules/@types/node/ts4.8/path.d.ts +168 -0
- package/dist/node_modules/@types/node/ts4.8/perf_hooks.d.ts +274 -0
- package/dist/node_modules/@types/node/ts4.8/process.d.ts +452 -0
- package/dist/node_modules/@types/node/ts4.8/punycode.d.ts +78 -0
- package/dist/node_modules/@types/node/ts4.8/querystring.d.ts +41 -0
- package/dist/node_modules/@types/node/ts4.8/readline.d.ts +184 -0
- package/dist/node_modules/@types/node/ts4.8/repl.d.ts +404 -0
- package/dist/node_modules/@types/node/ts4.8/stream.d.ts +518 -0
- package/dist/node_modules/@types/node/ts4.8/string_decoder.d.ts +10 -0
- package/dist/node_modules/@types/node/ts4.8/timers.d.ts +19 -0
- package/dist/node_modules/@types/node/ts4.8/tls.d.ts +866 -0
- package/dist/node_modules/@types/node/ts4.8/trace_events.d.ts +64 -0
- package/dist/node_modules/@types/node/ts4.8/tty.d.ts +69 -0
- package/dist/node_modules/@types/node/ts4.8/url.d.ts +187 -0
- package/dist/node_modules/@types/node/ts4.8/util.d.ts +278 -0
- package/dist/node_modules/@types/node/ts4.8/v8.d.ts +189 -0
- package/dist/node_modules/@types/node/ts4.8/vm.d.ts +155 -0
- package/dist/node_modules/@types/node/ts4.8/wasi.d.ts +88 -0
- package/dist/node_modules/@types/node/ts4.8/worker_threads.d.ts +241 -0
- package/dist/node_modules/@types/node/ts4.8/zlib.d.ts +364 -0
- package/dist/node_modules/@types/node/tty.d.ts +4 -4
- package/dist/node_modules/@types/node/url.d.ts +49 -11
- package/dist/node_modules/@types/node/util.d.ts +103 -41
- package/dist/node_modules/@types/node/v8.d.ts +4 -5
- package/dist/node_modules/@types/node/vm.d.ts +7 -7
- package/dist/node_modules/@types/node/wasi.d.ts +3 -4
- package/dist/node_modules/@types/node/worker_threads.d.ts +8 -8
- package/dist/node_modules/@types/node/zlib.d.ts +13 -13
- package/dist/node_modules/@types/progress/LICENSE +0 -0
- package/dist/node_modules/@types/progress/README.md +2 -3
- package/dist/node_modules/@types/progress/index.d.ts +0 -5
- package/dist/node_modules/@types/progress/package.json +6 -6
- package/dist/node_modules/ajv-formats/node_modules/ajv/README.md +19 -5
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/2019.d.ts +3 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/2019.js +7 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/2019.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/2020.d.ts +3 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/2020.js +7 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/2020.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/ajv.d.ts +3 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/ajv.js +7 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/ajv.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/codegen/code.d.ts +5 -5
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/codegen/code.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/codegen/index.d.ts +2 -2
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/codegen/index.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/codegen/scope.d.ts +5 -5
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/codegen/scope.js +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/errors.js +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/errors.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/index.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/index.js +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/index.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/jtd/parse.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/jtd/serialize.js +18 -7
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/jtd/serialize.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/jtd/types.d.ts +2 -2
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/names.js +6 -6
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/names.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/resolve.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/resolve.js +4 -4
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/resolve.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/rules.d.ts +2 -2
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/util.d.ts +2 -2
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/util.js +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/util.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/dataType.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/dataType.js +2 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/index.js +11 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/index.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/subschema.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/core.d.ts +3 -3
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/core.js +2 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/core.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/jtd.d.ts +4 -2
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/jtd.js +7 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/jtd.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/runtime/equal.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/runtime/parseJson.js +2 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/runtime/parseJson.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/runtime/re2.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/runtime/uri.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/standalone/index.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/types/index.d.ts +19 -19
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/types/json-schema.d.ts +15 -14
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/types/jtd-schema.d.ts +30 -25
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/additionalItems.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/anyOf.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/contains.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/dependencies.d.ts +2 -2
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/if.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/index.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/items2020.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/not.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/oneOf.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/applicator/propertyNames.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/code.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/discriminator/index.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/discriminator/types.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/discriminator/types.js +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/errors.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/format/format.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/discriminator.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/discriminator.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/elements.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/enum.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/enum.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/error.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/index.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/metadata.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/nullable.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/properties.d.ts +3 -3
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/properties.js +8 -5
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/properties.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/ref.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/type.d.ts +3 -3
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/type.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/values.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/values.js +10 -7
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/values.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/const.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/dependentRequired.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/enum.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/index.d.ts +2 -2
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/limitContains.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/limitNumber.d.ts +3 -3
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/multipleOf.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/pattern.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/required.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/uniqueItems.d.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/2019.ts +4 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/2020.ts +4 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/ajv.ts +4 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/codegen/index.ts +25 -5
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/jtd/serialize.ts +20 -14
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/jtd/types.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/resolve.ts +4 -4
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/rules.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/validate/dataType.ts +1 -0
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/validate/index.ts +10 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/core.ts +4 -0
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/jtd.ts +4 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/runtime/parseJson.ts +2 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/types/index.ts +7 -3
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/types/json-schema.ts +1 -0
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/types/jtd-schema.ts +21 -11
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/vocabularies/jtd/properties.ts +13 -6
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/vocabularies/jtd/values.ts +10 -7
- package/dist/node_modules/ajv-formats/node_modules/ajv/package.json +40 -40
- package/dist/node_modules/commander/Readme.md +407 -169
- package/dist/node_modules/commander/esm.mjs +13 -1
- package/dist/node_modules/commander/index.js +13 -2206
- package/dist/node_modules/commander/lib/argument.js +145 -0
- package/dist/node_modules/commander/lib/command.js +2299 -0
- package/dist/node_modules/commander/lib/error.js +43 -0
- package/dist/node_modules/commander/lib/help.js +457 -0
- package/dist/node_modules/commander/lib/option.js +327 -0
- package/dist/node_modules/commander/lib/suggestSimilar.js +100 -0
- package/dist/node_modules/commander/package.json +46 -34
- package/dist/node_modules/commander/typings/esm.d.mts +3 -0
- package/dist/node_modules/commander/typings/index.d.ts +889 -617
- package/dist/node_modules/graceful-fs/package.json +6 -3
- package/dist/node_modules/graceful-fs/polyfills.js +1 -1
- package/dist/node_modules/punycode/README.md +29 -3
- package/dist/node_modules/punycode/package.json +7 -7
- package/dist/node_modules/punycode/punycode.es6.js +25 -22
- package/dist/node_modules/punycode/punycode.js +25 -22
- package/dist/node_modules/universalify/README.md +1 -1
- package/dist/node_modules/universalify/index.js +6 -6
- package/dist/node_modules/universalify/package.json +2 -2
- package/dist/package.json +1 -2
- package/dist/util/cache/cloneIntoCache.js +1 -1
- package/dist/util/cache/getCachedItemPath.js +4 -2
- package/dist/util/cache/getJsonFromCachedFile.js +2 -2
- package/dist/util/getGitRepoNameFromUrl.js +1 -1
- package/dist/util/getRepositoryLatestTag.js +16 -0
- package/package.json +2 -3
- package/dist/node_modules/commander/CHANGELOG.md +0 -440
|
@@ -11,6 +11,7 @@ Read this in other languages: English | [简体中文](./Readme_zh-CN.md)
|
|
|
11
11
|
|
|
12
12
|
- [Commander.js](#commanderjs)
|
|
13
13
|
- [Installation](#installation)
|
|
14
|
+
- [Quick Start](#quick-start)
|
|
14
15
|
- [Declaring _program_ variable](#declaring-program-variable)
|
|
15
16
|
- [Options](#options)
|
|
16
17
|
- [Common option types, boolean and value](#common-option-types-boolean-and-value)
|
|
@@ -22,16 +23,22 @@ Read this in other languages: English | [简体中文](./Readme_zh-CN.md)
|
|
|
22
23
|
- [More configuration](#more-configuration)
|
|
23
24
|
- [Custom option processing](#custom-option-processing)
|
|
24
25
|
- [Commands](#commands)
|
|
25
|
-
- [
|
|
26
|
+
- [Command-arguments](#command-arguments)
|
|
27
|
+
- [More configuration](#more-configuration-1)
|
|
28
|
+
- [Custom argument processing](#custom-argument-processing)
|
|
26
29
|
- [Action handler](#action-handler)
|
|
27
30
|
- [Stand-alone executable (sub)commands](#stand-alone-executable-subcommands)
|
|
31
|
+
- [Life cycle hooks](#life-cycle-hooks)
|
|
28
32
|
- [Automated help](#automated-help)
|
|
29
33
|
- [Custom help](#custom-help)
|
|
34
|
+
- [Display help after errors](#display-help-after-errors)
|
|
30
35
|
- [Display help from code](#display-help-from-code)
|
|
31
|
-
- [.
|
|
36
|
+
- [.name](#name)
|
|
37
|
+
- [.usage](#usage)
|
|
38
|
+
- [.description and .summary](#description-and-summary)
|
|
32
39
|
- [.helpOption(flags, description)](#helpoptionflags-description)
|
|
33
|
-
- [.
|
|
34
|
-
- [More configuration](#more-configuration-
|
|
40
|
+
- [.helpCommand()](#helpcommand)
|
|
41
|
+
- [More configuration](#more-configuration-2)
|
|
35
42
|
- [Custom event listeners](#custom-event-listeners)
|
|
36
43
|
- [Bits and pieces](#bits-and-pieces)
|
|
37
44
|
- [.parse() and .parseAsync()](#parse-and-parseasync)
|
|
@@ -41,9 +48,10 @@ Read this in other languages: English | [简体中文](./Readme_zh-CN.md)
|
|
|
41
48
|
- [createCommand()](#createcommand)
|
|
42
49
|
- [Node options such as `--harmony`](#node-options-such-as---harmony)
|
|
43
50
|
- [Debugging stand-alone executable subcommands](#debugging-stand-alone-executable-subcommands)
|
|
51
|
+
- [npm run-script](#npm-run-script)
|
|
52
|
+
- [Display error](#display-error)
|
|
44
53
|
- [Override exit and output handling](#override-exit-and-output-handling)
|
|
45
54
|
- [Additional documentation](#additional-documentation)
|
|
46
|
-
- [Examples](#examples)
|
|
47
55
|
- [Support](#support)
|
|
48
56
|
- [Commander for enterprise](#commander-for-enterprise)
|
|
49
57
|
|
|
@@ -51,62 +59,150 @@ For information about terms used in this document see: [terminology](./docs/term
|
|
|
51
59
|
|
|
52
60
|
## Installation
|
|
53
61
|
|
|
54
|
-
```
|
|
62
|
+
```sh
|
|
55
63
|
npm install commander
|
|
56
64
|
```
|
|
57
65
|
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
You write code to describe your command line interface.
|
|
69
|
+
Commander looks after parsing the arguments into options and command-arguments,
|
|
70
|
+
displays usage errors for problems, and implements a help system.
|
|
71
|
+
|
|
72
|
+
Commander is strict and displays an error for unrecognised options.
|
|
73
|
+
The two most used option types are a boolean option, and an option which takes its value from the following argument.
|
|
74
|
+
|
|
75
|
+
Example file: [split.js](./examples/split.js)
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
const { program } = require('commander');
|
|
79
|
+
|
|
80
|
+
program
|
|
81
|
+
.option('--first')
|
|
82
|
+
.option('-s, --separator <char>');
|
|
83
|
+
|
|
84
|
+
program.parse();
|
|
85
|
+
|
|
86
|
+
const options = program.opts();
|
|
87
|
+
const limit = options.first ? 1 : undefined;
|
|
88
|
+
console.log(program.args[0].split(options.separator, limit));
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```console
|
|
92
|
+
$ node split.js -s / --fits a/b/c
|
|
93
|
+
error: unknown option '--fits'
|
|
94
|
+
(Did you mean --first?)
|
|
95
|
+
$ node split.js -s / --first a/b/c
|
|
96
|
+
[ 'a' ]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Here is a more complete program using a subcommand and with descriptions for the help. In a multi-command program, you have an action handler for each command (or stand-alone executables for the commands).
|
|
100
|
+
|
|
101
|
+
Example file: [string-util.js](./examples/string-util.js)
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
const { Command } = require('commander');
|
|
105
|
+
const program = new Command();
|
|
106
|
+
|
|
107
|
+
program
|
|
108
|
+
.name('string-util')
|
|
109
|
+
.description('CLI to some JavaScript string utilities')
|
|
110
|
+
.version('0.8.0');
|
|
111
|
+
|
|
112
|
+
program.command('split')
|
|
113
|
+
.description('Split a string into substrings and display as an array')
|
|
114
|
+
.argument('<string>', 'string to split')
|
|
115
|
+
.option('--first', 'display just the first substring')
|
|
116
|
+
.option('-s, --separator <char>', 'separator character', ',')
|
|
117
|
+
.action((str, options) => {
|
|
118
|
+
const limit = options.first ? 1 : undefined;
|
|
119
|
+
console.log(str.split(options.separator, limit));
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
program.parse();
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```console
|
|
126
|
+
$ node string-util.js help split
|
|
127
|
+
Usage: string-util split [options] <string>
|
|
128
|
+
|
|
129
|
+
Split a string into substrings and display as an array.
|
|
130
|
+
|
|
131
|
+
Arguments:
|
|
132
|
+
string string to split
|
|
133
|
+
|
|
134
|
+
Options:
|
|
135
|
+
--first display just the first substring
|
|
136
|
+
-s, --separator <char> separator character (default: ",")
|
|
137
|
+
-h, --help display help for command
|
|
138
|
+
|
|
139
|
+
$ node string-util.js split --separator=/ a/b/c
|
|
140
|
+
[ 'a', 'b', 'c' ]
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
More samples can be found in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory.
|
|
144
|
+
|
|
58
145
|
## Declaring _program_ variable
|
|
59
146
|
|
|
60
147
|
Commander exports a global object which is convenient for quick programs.
|
|
61
148
|
This is used in the examples in this README for brevity.
|
|
62
149
|
|
|
63
150
|
```js
|
|
151
|
+
// CommonJS (.cjs)
|
|
64
152
|
const { program } = require('commander');
|
|
65
|
-
program.version('0.0.1');
|
|
66
153
|
```
|
|
67
154
|
|
|
68
155
|
For larger programs which may use commander in multiple ways, including unit testing, it is better to create a local Command object to use.
|
|
69
156
|
|
|
70
157
|
```js
|
|
158
|
+
// CommonJS (.cjs)
|
|
71
159
|
const { Command } = require('commander');
|
|
72
160
|
const program = new Command();
|
|
73
|
-
program.version('0.0.1');
|
|
74
161
|
```
|
|
75
162
|
|
|
76
|
-
For named imports in ECMAScript modules, import from `commander/esm.mjs`.
|
|
77
|
-
|
|
78
163
|
```js
|
|
79
|
-
//
|
|
80
|
-
import { Command } from 'commander
|
|
164
|
+
// ECMAScript (.mjs)
|
|
165
|
+
import { Command } from 'commander';
|
|
81
166
|
const program = new Command();
|
|
82
167
|
```
|
|
83
168
|
|
|
84
|
-
And in TypeScript:
|
|
85
|
-
|
|
86
169
|
```ts
|
|
87
|
-
//
|
|
170
|
+
// TypeScript (.ts)
|
|
88
171
|
import { Command } from 'commander';
|
|
89
172
|
const program = new Command();
|
|
90
173
|
```
|
|
91
174
|
|
|
92
|
-
|
|
93
175
|
## Options
|
|
94
176
|
|
|
95
177
|
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 ('|').
|
|
96
178
|
|
|
97
|
-
The parsed options can be accessed by calling `.opts()` on a `Command` object, and are passed to the action handler.
|
|
179
|
+
The parsed options can be accessed by calling `.opts()` on a `Command` object, and are passed to the action handler.
|
|
180
|
+
|
|
181
|
+
Multi-word options such as "--template-engine" are camel-cased, becoming `program.opts().templateEngine` etc.
|
|
182
|
+
|
|
183
|
+
An option and its option-argument can be separated by a space, or combined into the same argument. The option-argument can follow the short option directly or follow an `=` for a long option.
|
|
98
184
|
|
|
99
|
-
|
|
100
|
-
|
|
185
|
+
```sh
|
|
186
|
+
serve -p 80
|
|
187
|
+
serve -p80
|
|
188
|
+
serve --port 80
|
|
189
|
+
serve --port=80
|
|
190
|
+
```
|
|
101
191
|
|
|
102
192
|
You can use `--` to indicate the end of the options, and any remaining arguments will be used without being interpreted.
|
|
103
193
|
|
|
104
|
-
By default options on the command line are not positional, and can be specified before or after other arguments.
|
|
194
|
+
By default, options on the command line are not positional, and can be specified before or after other arguments.
|
|
195
|
+
|
|
196
|
+
There are additional related routines for when `.opts()` is not enough:
|
|
197
|
+
|
|
198
|
+
- `.optsWithGlobals()` returns merged local and global option values
|
|
199
|
+
- `.getOptionValue()` and `.setOptionValue()` work with a single option value
|
|
200
|
+
- `.getOptionValueSource()` and `.setOptionValueWithSource()` include where the option value came from
|
|
105
201
|
|
|
106
202
|
### Common option types, boolean and value
|
|
107
203
|
|
|
108
204
|
The two most used option types are a boolean option, and an option which takes its value
|
|
109
|
-
from the following argument (declared with angle brackets like `--expect <value>`). Both are `undefined` unless specified on command line.
|
|
205
|
+
from the following argument (declared with angle brackets like `--expect <value>`). Both are `undefined` unless specified on command line.
|
|
110
206
|
|
|
111
207
|
Example file: [options-common.js](./examples/options-common.js)
|
|
112
208
|
|
|
@@ -125,13 +221,10 @@ if (options.small) console.log('- small pizza size');
|
|
|
125
221
|
if (options.pizzaType) console.log(`- ${options.pizzaType}`);
|
|
126
222
|
```
|
|
127
223
|
|
|
128
|
-
```
|
|
129
|
-
$ pizza-options -d
|
|
130
|
-
{ debug: true, small: undefined, pizzaType: undefined }
|
|
131
|
-
pizza details:
|
|
224
|
+
```console
|
|
132
225
|
$ pizza-options -p
|
|
133
226
|
error: option '-p, --pizza-type <type>' argument missing
|
|
134
|
-
$ pizza-options -
|
|
227
|
+
$ pizza-options -d -s -p vegetarian
|
|
135
228
|
{ debug: true, small: true, pizzaType: 'vegetarian' }
|
|
136
229
|
pizza details:
|
|
137
230
|
- small pizza size
|
|
@@ -141,11 +234,17 @@ pizza details:
|
|
|
141
234
|
- cheese
|
|
142
235
|
```
|
|
143
236
|
|
|
237
|
+
Multiple boolean short options may be combined following the dash, and may be followed by a single short option taking a value.
|
|
238
|
+
For example `-d -s -p cheese` may be written as `-ds -p cheese` or even `-dsp cheese`.
|
|
239
|
+
|
|
240
|
+
Options with an expected option-argument are greedy and will consume the following argument whatever the value.
|
|
241
|
+
So `--id -xyz` reads `-xyz` as the option-argument.
|
|
242
|
+
|
|
144
243
|
`program.parse(arguments)` processes the arguments, leaving any args not consumed by the program options in the `program.args` array. The parameter is optional and defaults to `process.argv`.
|
|
145
244
|
|
|
146
245
|
### Default option value
|
|
147
246
|
|
|
148
|
-
You can specify a default value for an option
|
|
247
|
+
You can specify a default value for an option.
|
|
149
248
|
|
|
150
249
|
Example file: [options-defaults.js](./examples/options-defaults.js)
|
|
151
250
|
|
|
@@ -158,7 +257,7 @@ program.parse();
|
|
|
158
257
|
console.log(`cheese: ${program.opts().cheese}`);
|
|
159
258
|
```
|
|
160
259
|
|
|
161
|
-
```
|
|
260
|
+
```console
|
|
162
261
|
$ pizza-options
|
|
163
262
|
cheese: blue
|
|
164
263
|
$ pizza-options --cheese stilton
|
|
@@ -171,7 +270,7 @@ You can define a boolean option long name with a leading `no-` to set the option
|
|
|
171
270
|
Defined alone this also makes the option true by default.
|
|
172
271
|
|
|
173
272
|
If you define `--foo` first, adding `--no-foo` does not change the default value from what it would
|
|
174
|
-
otherwise be.
|
|
273
|
+
otherwise be.
|
|
175
274
|
|
|
176
275
|
Example file: [options-negatable.js](./examples/options-negatable.js)
|
|
177
276
|
|
|
@@ -188,7 +287,7 @@ const cheeseStr = (options.cheese === false) ? 'no cheese' : `${options.cheese}
|
|
|
188
287
|
console.log(`You ordered a pizza with ${sauceStr} and ${cheeseStr}`);
|
|
189
288
|
```
|
|
190
289
|
|
|
191
|
-
```
|
|
290
|
+
```console
|
|
192
291
|
$ pizza-options
|
|
193
292
|
You ordered a pizza with sauce and mozzarella cheese
|
|
194
293
|
$ pizza-options --sauce
|
|
@@ -216,7 +315,7 @@ else if (options.cheese === true) console.log('add cheese');
|
|
|
216
315
|
else console.log(`add cheese type ${options.cheese}`);
|
|
217
316
|
```
|
|
218
317
|
|
|
219
|
-
```
|
|
318
|
+
```console
|
|
220
319
|
$ pizza-options
|
|
221
320
|
no cheese
|
|
222
321
|
$ pizza-options --cheese
|
|
@@ -225,11 +324,14 @@ $ pizza-options --cheese mozzarella
|
|
|
225
324
|
add cheese type mozzarella
|
|
226
325
|
```
|
|
227
326
|
|
|
228
|
-
|
|
327
|
+
Options with an optional option-argument are not greedy and will ignore arguments starting with a dash.
|
|
328
|
+
So `id` behaves as a boolean option for `--id -5`, but you can use a combined form if needed like `--id=-5`.
|
|
329
|
+
|
|
330
|
+
For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-in-depth.md).
|
|
229
331
|
|
|
230
332
|
### Required option
|
|
231
333
|
|
|
232
|
-
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.
|
|
334
|
+
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.
|
|
233
335
|
|
|
234
336
|
Example file: [options-required.js](./examples/options-required.js)
|
|
235
337
|
|
|
@@ -240,7 +342,7 @@ program
|
|
|
240
342
|
program.parse();
|
|
241
343
|
```
|
|
242
344
|
|
|
243
|
-
```
|
|
345
|
+
```console
|
|
244
346
|
$ pizza
|
|
245
347
|
error: required option '-c, --cheese <type>' not specified
|
|
246
348
|
```
|
|
@@ -265,7 +367,7 @@ console.log('Options: ', program.opts());
|
|
|
265
367
|
console.log('Remaining arguments: ', program.args);
|
|
266
368
|
```
|
|
267
369
|
|
|
268
|
-
```
|
|
370
|
+
```console
|
|
269
371
|
$ collect -n 1 2 3 --letter a b c
|
|
270
372
|
Options: { number: [ '1', '2', '3' ], letter: [ 'a', 'b', 'c' ] }
|
|
271
373
|
Remaining arguments: []
|
|
@@ -277,7 +379,7 @@ Options: { number: [ '1', '2', '3' ], letter: true }
|
|
|
277
379
|
Remaining arguments: [ 'operand' ]
|
|
278
380
|
```
|
|
279
381
|
|
|
280
|
-
For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-
|
|
382
|
+
For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-in-depth.md).
|
|
281
383
|
|
|
282
384
|
### Version option
|
|
283
385
|
|
|
@@ -287,7 +389,7 @@ The optional `version` method adds handling for displaying the command version.
|
|
|
287
389
|
program.version('0.0.1');
|
|
288
390
|
```
|
|
289
391
|
|
|
290
|
-
```
|
|
392
|
+
```console
|
|
291
393
|
$ ./examples/pizza -V
|
|
292
394
|
0.0.1
|
|
293
395
|
```
|
|
@@ -304,28 +406,44 @@ program.version('0.0.1', '-v, --vers', 'output the current version');
|
|
|
304
406
|
You can add most options using the `.option()` method, but there are some additional features available
|
|
305
407
|
by constructing an `Option` explicitly for less common cases.
|
|
306
408
|
|
|
307
|
-
Example
|
|
409
|
+
Example files: [options-extra.js](./examples/options-extra.js), [options-env.js](./examples/options-env.js), [options-conflicts.js](./examples/options-conflicts.js), [options-implies.js](./examples/options-implies.js)
|
|
308
410
|
|
|
309
411
|
```js
|
|
310
412
|
program
|
|
311
413
|
.addOption(new Option('-s, --secret').hideHelp())
|
|
312
414
|
.addOption(new Option('-t, --timeout <delay>', 'timeout in seconds').default(60, 'one minute'))
|
|
313
|
-
.addOption(new Option('-d, --drink <size>', 'drink size').choices(['small', 'medium', 'large']))
|
|
415
|
+
.addOption(new Option('-d, --drink <size>', 'drink size').choices(['small', 'medium', 'large']))
|
|
416
|
+
.addOption(new Option('-p, --port <number>', 'port number').env('PORT'))
|
|
417
|
+
.addOption(new Option('--donate [amount]', 'optional donation in dollars').preset('20').argParser(parseFloat))
|
|
418
|
+
.addOption(new Option('--disable-server', 'disables the server').conflicts('port'))
|
|
419
|
+
.addOption(new Option('--free-drink', 'small drink included free ').implies({ drink: 'small' }));
|
|
314
420
|
```
|
|
315
421
|
|
|
316
|
-
```
|
|
422
|
+
```console
|
|
317
423
|
$ extra --help
|
|
318
424
|
Usage: help [options]
|
|
319
425
|
|
|
320
426
|
Options:
|
|
321
427
|
-t, --timeout <delay> timeout in seconds (default: one minute)
|
|
322
428
|
-d, --drink <size> drink cup size (choices: "small", "medium", "large")
|
|
429
|
+
-p, --port <number> port number (env: PORT)
|
|
430
|
+
--donate [amount] optional donation in dollars (preset: "20")
|
|
431
|
+
--disable-server disables the server
|
|
432
|
+
--free-drink small drink included free
|
|
323
433
|
-h, --help display help for command
|
|
324
434
|
|
|
325
435
|
$ extra --drink huge
|
|
326
436
|
error: option '-d, --drink <size>' argument 'huge' is invalid. Allowed choices are small, medium, large.
|
|
437
|
+
|
|
438
|
+
$ PORT=80 extra --donate --free-drink
|
|
439
|
+
Options: { timeout: 60, donate: 20, port: '80', freeDrink: true, drink: 'small' }
|
|
440
|
+
|
|
441
|
+
$ extra --disable-server --port 8000
|
|
442
|
+
error: option '--disable-server' cannot be used with option '-p, --port <number>'
|
|
327
443
|
```
|
|
328
444
|
|
|
445
|
+
Specify a required (mandatory) option using the `Option` method `.makeOptionMandatory()`. This matches the `Command` method [.requiredOption()](#required-option).
|
|
446
|
+
|
|
329
447
|
### Custom option processing
|
|
330
448
|
|
|
331
449
|
You may specify a function to do custom processing of option-arguments. The callback function receives two parameters,
|
|
@@ -342,7 +460,7 @@ function myParseInt(value, dummyPrevious) {
|
|
|
342
460
|
// parseInt takes a string and a radix
|
|
343
461
|
const parsedValue = parseInt(value, 10);
|
|
344
462
|
if (isNaN(parsedValue)) {
|
|
345
|
-
throw new commander.
|
|
463
|
+
throw new commander.InvalidArgumentError('Not a number.');
|
|
346
464
|
}
|
|
347
465
|
return parsedValue;
|
|
348
466
|
}
|
|
@@ -377,7 +495,7 @@ if (options.collect.length > 0) console.log(options.collect);
|
|
|
377
495
|
if (options.list !== undefined) console.log(options.list);
|
|
378
496
|
```
|
|
379
497
|
|
|
380
|
-
```
|
|
498
|
+
```console
|
|
381
499
|
$ custom -f 1e2
|
|
382
500
|
float: 100
|
|
383
501
|
$ custom --integer 2
|
|
@@ -394,7 +512,7 @@ $ custom --list x,y,z
|
|
|
394
512
|
|
|
395
513
|
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)).
|
|
396
514
|
|
|
397
|
-
In the first parameter to `.command()` you specify the command name
|
|
515
|
+
In the first parameter to `.command()` you specify the command name. You may append the command-arguments after the command name, or specify them separately using `.argument()`. The arguments may be `<required>` or `[optional]`, and the last argument may also be `variadic...`.
|
|
398
516
|
|
|
399
517
|
You can use `.addCommand()` to add an already configured subcommand to the program.
|
|
400
518
|
|
|
@@ -410,7 +528,7 @@ program
|
|
|
410
528
|
console.log('clone command called');
|
|
411
529
|
});
|
|
412
530
|
|
|
413
|
-
// Command implemented using stand-alone executable file
|
|
531
|
+
// Command implemented using stand-alone executable file, indicated by adding description as second parameter to `.command`.
|
|
414
532
|
// Returns `this` for adding more commands.
|
|
415
533
|
program
|
|
416
534
|
.command('start <service>', 'start named service')
|
|
@@ -422,40 +540,47 @@ program
|
|
|
422
540
|
.addCommand(build.makeBuildCommand());
|
|
423
541
|
```
|
|
424
542
|
|
|
425
|
-
Configuration options can be passed with the call to `.command()` and `.addCommand()`. Specifying `hidden: true` will
|
|
543
|
+
Configuration options can be passed with the call to `.command()` and `.addCommand()`. Specifying `hidden: true` will
|
|
426
544
|
remove the command from the generated help output. Specifying `isDefault: true` will run the subcommand if no other
|
|
427
545
|
subcommand is specified ([example](./examples/defaultCommand.js)).
|
|
428
546
|
|
|
429
|
-
|
|
547
|
+
You can add alternative names for a command with `.alias()`. ([example](./examples/alias.js))
|
|
548
|
+
|
|
549
|
+
`.command()` automatically copies the inherited settings from the parent command to the newly created subcommand. This is only done during creation, any later setting changes to the parent are not inherited.
|
|
430
550
|
|
|
431
|
-
|
|
432
|
-
included in the `.command` call. Angled brackets (e.g. `<required>`) indicate required command-arguments.
|
|
433
|
-
Square brackets (e.g. `[optional]`) indicate optional command-arguments.
|
|
434
|
-
You can optionally describe the arguments in the help by supplying a hash as second parameter to `.description()`.
|
|
551
|
+
For safety, `.addCommand()` does not automatically copy the inherited settings from the parent command. There is a helper routine `.copyInheritedSettings()` for copying the settings when they are wanted.
|
|
435
552
|
|
|
436
|
-
|
|
553
|
+
### Command-arguments
|
|
554
|
+
|
|
555
|
+
For subcommands, you can specify the argument syntax in the call to `.command()` (as shown above). This
|
|
556
|
+
is the only method usable for subcommands implemented using a stand-alone executable, but for other subcommands
|
|
557
|
+
you can instead use the following method.
|
|
558
|
+
|
|
559
|
+
To configure a command, you can use `.argument()` to specify each expected command-argument.
|
|
560
|
+
You supply the argument name and an optional description. The argument may be `<required>` or `[optional]`.
|
|
561
|
+
You can specify a default value for an optional command-argument.
|
|
562
|
+
|
|
563
|
+
Example file: [argument.js](./examples/argument.js)
|
|
437
564
|
|
|
438
565
|
```js
|
|
439
566
|
program
|
|
440
567
|
.version('0.1.0')
|
|
441
|
-
.
|
|
442
|
-
.
|
|
443
|
-
username: 'user to login',
|
|
444
|
-
password: 'password for user, if required'
|
|
445
|
-
})
|
|
568
|
+
.argument('<username>', 'user to login')
|
|
569
|
+
.argument('[password]', 'password for user, if required', 'no password given')
|
|
446
570
|
.action((username, password) => {
|
|
447
571
|
console.log('username:', username);
|
|
448
|
-
console.log('
|
|
572
|
+
console.log('password:', password);
|
|
449
573
|
});
|
|
450
574
|
```
|
|
451
575
|
|
|
452
576
|
The last argument of a command can be variadic, and only the last argument. To make an argument variadic you
|
|
453
|
-
append `...` to the argument name. For example:
|
|
577
|
+
append `...` to the argument name. A variadic argument is passed to the action handler as an array. For example:
|
|
454
578
|
|
|
455
579
|
```js
|
|
456
580
|
program
|
|
457
581
|
.version('0.1.0')
|
|
458
|
-
.command('rmdir
|
|
582
|
+
.command('rmdir')
|
|
583
|
+
.argument('<dirs...>')
|
|
459
584
|
.action(function (dirs) {
|
|
460
585
|
dirs.forEach((dir) => {
|
|
461
586
|
console.log('rmdir %s', dir);
|
|
@@ -463,18 +588,58 @@ program
|
|
|
463
588
|
});
|
|
464
589
|
```
|
|
465
590
|
|
|
466
|
-
|
|
591
|
+
There is a convenience method to add multiple arguments at once, but without descriptions:
|
|
592
|
+
|
|
593
|
+
```js
|
|
594
|
+
program
|
|
595
|
+
.arguments('<username> <password>');
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
#### More configuration
|
|
599
|
+
|
|
600
|
+
There are some additional features available by constructing an `Argument` explicitly for less common cases.
|
|
601
|
+
|
|
602
|
+
Example file: [arguments-extra.js](./examples/arguments-extra.js)
|
|
603
|
+
|
|
604
|
+
```js
|
|
605
|
+
program
|
|
606
|
+
.addArgument(new commander.Argument('<drink-size>', 'drink cup size').choices(['small', 'medium', 'large']))
|
|
607
|
+
.addArgument(new commander.Argument('[timeout]', 'timeout in seconds').default(60, 'one minute'))
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
#### Custom argument processing
|
|
611
|
+
|
|
612
|
+
You may specify a function to do custom processing of command-arguments (like for option-arguments).
|
|
613
|
+
The callback function receives two parameters, the user specified command-argument and the previous value for the argument.
|
|
614
|
+
It returns the new value for the argument.
|
|
615
|
+
|
|
616
|
+
The processed argument values are passed to the action handler, and saved as `.processedArgs`.
|
|
617
|
+
|
|
618
|
+
You can optionally specify the default/starting value for the argument after the function parameter.
|
|
619
|
+
|
|
620
|
+
Example file: [arguments-custom-processing.js](./examples/arguments-custom-processing.js)
|
|
621
|
+
|
|
622
|
+
```js
|
|
623
|
+
program
|
|
624
|
+
.command('add')
|
|
625
|
+
.argument('<first>', 'integer argument', myParseInt)
|
|
626
|
+
.argument('[second]', 'integer argument', myParseInt, 1000)
|
|
627
|
+
.action((first, second) => {
|
|
628
|
+
console.log(`${first} + ${second} = ${first + second}`);
|
|
629
|
+
})
|
|
630
|
+
;
|
|
631
|
+
```
|
|
467
632
|
|
|
468
633
|
### Action handler
|
|
469
634
|
|
|
470
635
|
The action handler gets passed a parameter for each command-argument you declared, and two additional parameters
|
|
471
|
-
which are the parsed options and the command object itself.
|
|
636
|
+
which are the parsed options and the command object itself.
|
|
472
637
|
|
|
473
638
|
Example file: [thank.js](./examples/thank.js)
|
|
474
639
|
|
|
475
640
|
```js
|
|
476
641
|
program
|
|
477
|
-
.
|
|
642
|
+
.argument('<name>')
|
|
478
643
|
.option('-t, --title <honorific>', 'title to use before name')
|
|
479
644
|
.option('-d, --debug', 'display some debugging')
|
|
480
645
|
.action((name, options, command) => {
|
|
@@ -486,6 +651,20 @@ program
|
|
|
486
651
|
});
|
|
487
652
|
```
|
|
488
653
|
|
|
654
|
+
If you prefer, you can work with the command directly and skip declaring the parameters for the action handler. The `this` keyword is set to the running command and can be used from a function expression (but not from an arrow function).
|
|
655
|
+
|
|
656
|
+
Example file: [action-this.js](./examples/action-this.js)
|
|
657
|
+
|
|
658
|
+
```js
|
|
659
|
+
program
|
|
660
|
+
.command('serve')
|
|
661
|
+
.argument('<script>')
|
|
662
|
+
.option('-p, --port <number>', 'port number', 80)
|
|
663
|
+
.action(function() {
|
|
664
|
+
console.error('Run script %s on port %s', this.args[0], this.opts().port);
|
|
665
|
+
});
|
|
666
|
+
```
|
|
667
|
+
|
|
489
668
|
You may supply an `async` action handler, in which case you call `.parseAsync` rather than `.parse`.
|
|
490
669
|
|
|
491
670
|
```js
|
|
@@ -499,14 +678,15 @@ async function main() {
|
|
|
499
678
|
}
|
|
500
679
|
```
|
|
501
680
|
|
|
502
|
-
A command's options and arguments on the command line are validated when the command is used. Any unknown options or missing arguments will be reported as an error. You can suppress the unknown option checks with `.allowUnknownOption()`. By default it is not an error to
|
|
681
|
+
A command's options and arguments on the command line are validated when the command is used. Any unknown options or missing arguments will be reported as an error. You can suppress the unknown option checks with `.allowUnknownOption()`. By default, it is not an error to
|
|
503
682
|
pass more arguments than declared, but you can make this an error with `.allowExcessArguments(false)`.
|
|
504
683
|
|
|
505
684
|
### Stand-alone executable (sub)commands
|
|
506
685
|
|
|
507
686
|
When `.command()` is invoked with a description argument, this tells Commander that you're going to use stand-alone executables for subcommands.
|
|
508
|
-
Commander will search the
|
|
509
|
-
You
|
|
687
|
+
Commander will search the files in the directory of the entry script for a file with the name combination `command-subcommand`, like `pm-install` or `pm-search` in the example below. The search includes trying common file extensions, like `.js`.
|
|
688
|
+
You may specify a custom name (and path) with the `executableFile` configuration option.
|
|
689
|
+
You may specify a custom search directory for subcommands with `.executableDir()`.
|
|
510
690
|
|
|
511
691
|
You handle the options for an executable (sub)command in the executable, and don't declare them at the top-level.
|
|
512
692
|
|
|
@@ -514,6 +694,7 @@ Example file: [pm](./examples/pm)
|
|
|
514
694
|
|
|
515
695
|
```js
|
|
516
696
|
program
|
|
697
|
+
.name('pm')
|
|
517
698
|
.version('0.1.0')
|
|
518
699
|
.command('install [name]', 'install one or more packages')
|
|
519
700
|
.command('search [query]', 'search with optional query')
|
|
@@ -525,6 +706,35 @@ program.parse(process.argv);
|
|
|
525
706
|
|
|
526
707
|
If the program is designed to be installed globally, make sure the executables have proper modes, like `755`.
|
|
527
708
|
|
|
709
|
+
### Life cycle hooks
|
|
710
|
+
|
|
711
|
+
You can add callback hooks to a command for life cycle events.
|
|
712
|
+
|
|
713
|
+
Example file: [hook.js](./examples/hook.js)
|
|
714
|
+
|
|
715
|
+
```js
|
|
716
|
+
program
|
|
717
|
+
.option('-t, --trace', 'display trace statements for commands')
|
|
718
|
+
.hook('preAction', (thisCommand, actionCommand) => {
|
|
719
|
+
if (thisCommand.opts().trace) {
|
|
720
|
+
console.log(`About to call action handler for subcommand: ${actionCommand.name()}`);
|
|
721
|
+
console.log('arguments: %O', actionCommand.args);
|
|
722
|
+
console.log('options: %o', actionCommand.opts());
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
The callback hook can be `async`, in which case you call `.parseAsync` rather than `.parse`. You can add multiple hooks per event.
|
|
728
|
+
|
|
729
|
+
The supported events are:
|
|
730
|
+
|
|
731
|
+
| event name | when hook called | callback parameters |
|
|
732
|
+
| :-- | :-- | :-- |
|
|
733
|
+
| `preAction`, `postAction` | before/after action handler for this command and its nested subcommands | `(thisCommand, actionCommand)` |
|
|
734
|
+
| `preSubcommand` | before parsing direct subcommand | `(thisCommand, subcommand)` |
|
|
735
|
+
|
|
736
|
+
For an overview of the life cycle events see [parsing life cycle and hooks](./docs/parsing-and-hooks.md).
|
|
737
|
+
|
|
528
738
|
## Automated help
|
|
529
739
|
|
|
530
740
|
The help information is auto-generated based on the information commander already knows about your program. The default
|
|
@@ -532,7 +742,7 @@ help option is `-h,--help`.
|
|
|
532
742
|
|
|
533
743
|
Example file: [pizza](./examples/pizza)
|
|
534
744
|
|
|
535
|
-
```
|
|
745
|
+
```console
|
|
536
746
|
$ node ./examples/pizza --help
|
|
537
747
|
Usage: pizza [options]
|
|
538
748
|
|
|
@@ -548,7 +758,7 @@ Options:
|
|
|
548
758
|
A `help` command is added by default if your command has subcommands. It can be used alone, or with a subcommand name to show
|
|
549
759
|
further help for the subcommand. These are effectively the same if the `shell` program has implicit help:
|
|
550
760
|
|
|
551
|
-
```
|
|
761
|
+
```sh
|
|
552
762
|
shell help
|
|
553
763
|
shell --help
|
|
554
764
|
|
|
@@ -556,9 +766,11 @@ shell help spawn
|
|
|
556
766
|
shell spawn --help
|
|
557
767
|
```
|
|
558
768
|
|
|
769
|
+
Long descriptions are wrapped to fit the available width. (However, a description that includes a line-break followed by whitespace is assumed to be pre-formatted and not wrapped.)
|
|
770
|
+
|
|
559
771
|
### Custom help
|
|
560
772
|
|
|
561
|
-
You can add extra text to be displayed along with the built-in help.
|
|
773
|
+
You can add extra text to be displayed along with the built-in help.
|
|
562
774
|
|
|
563
775
|
Example file: [custom-help](./examples/custom-help)
|
|
564
776
|
|
|
@@ -592,13 +804,43 @@ The positions in order displayed are:
|
|
|
592
804
|
- `after`: display extra information after built-in help
|
|
593
805
|
- `afterAll`: add to the program for a global footer (epilog)
|
|
594
806
|
|
|
595
|
-
The positions "beforeAll" and "afterAll" apply to the command and all its subcommands.
|
|
807
|
+
The positions "beforeAll" and "afterAll" apply to the command and all its subcommands.
|
|
596
808
|
|
|
597
809
|
The second parameter can be a string, or a function returning a string. The function is passed a context object for your convenience. The properties are:
|
|
598
810
|
|
|
599
811
|
- error: a boolean for whether the help is being displayed due to a usage error
|
|
600
812
|
- command: the Command which is displaying the help
|
|
601
813
|
|
|
814
|
+
### Display help after errors
|
|
815
|
+
|
|
816
|
+
The default behaviour for usage errors is to just display a short error message.
|
|
817
|
+
You can change the behaviour to show the full help or a custom help message after an error.
|
|
818
|
+
|
|
819
|
+
```js
|
|
820
|
+
program.showHelpAfterError();
|
|
821
|
+
// or
|
|
822
|
+
program.showHelpAfterError('(add --help for additional information)');
|
|
823
|
+
```
|
|
824
|
+
|
|
825
|
+
```console
|
|
826
|
+
$ pizza --unknown
|
|
827
|
+
error: unknown option '--unknown'
|
|
828
|
+
(add --help for additional information)
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
The default behaviour is to suggest correct spelling after an error for an unknown command or option. You
|
|
832
|
+
can disable this.
|
|
833
|
+
|
|
834
|
+
```js
|
|
835
|
+
program.showSuggestionAfterError(false);
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
```console
|
|
839
|
+
$ pizza --hepl
|
|
840
|
+
error: unknown option '--hepl'
|
|
841
|
+
(Did you mean --help?)
|
|
842
|
+
```
|
|
843
|
+
|
|
602
844
|
### Display help from code
|
|
603
845
|
|
|
604
846
|
`.help()`: display help information and exit immediately. You can optionally pass `{ error: true }` to display on stderr and exit with an error status.
|
|
@@ -607,10 +849,25 @@ The second parameter can be a string, or a function returning a string. The func
|
|
|
607
849
|
|
|
608
850
|
`.helpInformation()`: get the built-in command help information as a string for processing or displaying yourself.
|
|
609
851
|
|
|
610
|
-
### .
|
|
852
|
+
### .name
|
|
853
|
+
|
|
854
|
+
The command name appears in the help, and is also used for locating stand-alone executable subcommands.
|
|
855
|
+
|
|
856
|
+
You may specify the program name using `.name()` or in the Command constructor. For the program, Commander will
|
|
857
|
+
fall back to using the script name from the full arguments passed into `.parse()`. However, the script name varies
|
|
858
|
+
depending on how your program is launched, so you may wish to specify it explicitly.
|
|
859
|
+
|
|
860
|
+
```js
|
|
861
|
+
program.name('pizza');
|
|
862
|
+
const pm = new Command('pm');
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
Subcommands get a name when specified using `.command()`. If you create the subcommand yourself to use with `.addCommand()`,
|
|
866
|
+
then set the name using `.name()` or in the Command constructor.
|
|
867
|
+
|
|
868
|
+
### .usage
|
|
611
869
|
|
|
612
|
-
|
|
613
|
-
deduced from the (full) program arguments. Given:
|
|
870
|
+
This allows you to customise the usage description in the first line of the help. Given:
|
|
614
871
|
|
|
615
872
|
```js
|
|
616
873
|
program
|
|
@@ -624,25 +881,43 @@ The help will start with:
|
|
|
624
881
|
Usage: my-command [global options] command
|
|
625
882
|
```
|
|
626
883
|
|
|
884
|
+
### .description and .summary
|
|
885
|
+
|
|
886
|
+
The description appears in the help for the command. You can optionally supply a shorter
|
|
887
|
+
summary to use when listed as a subcommand of the program.
|
|
888
|
+
|
|
889
|
+
```js
|
|
890
|
+
program
|
|
891
|
+
.command("duplicate")
|
|
892
|
+
.summary("make a copy")
|
|
893
|
+
.description(`Make a copy of the current project.
|
|
894
|
+
This may require additional disk space.
|
|
895
|
+
`);
|
|
896
|
+
```
|
|
897
|
+
|
|
627
898
|
### .helpOption(flags, description)
|
|
628
899
|
|
|
629
|
-
By default every command has a help option.
|
|
900
|
+
By default, every command has a help option. You may change the default help flags and description. Pass false to disable the built-in help option.
|
|
630
901
|
|
|
631
902
|
```js
|
|
632
903
|
program
|
|
633
904
|
.helpOption('-e, --HELP', 'read more information');
|
|
634
905
|
```
|
|
635
906
|
|
|
636
|
-
|
|
907
|
+
(Or use `.addHelpOption()` to add an option you construct yourself.)
|
|
637
908
|
|
|
638
|
-
|
|
909
|
+
### .helpCommand()
|
|
910
|
+
|
|
911
|
+
A help command is added by default if your command has subcommands. You can explicitly turn on or off the implicit help command with `.helpCommand(true)` and `.helpCommand(false)`.
|
|
639
912
|
|
|
640
913
|
You can both turn on and customise the help command by supplying the name and description:
|
|
641
914
|
|
|
642
915
|
```js
|
|
643
|
-
program.
|
|
916
|
+
program.helpCommand('assist [command]', 'show assistance');
|
|
644
917
|
```
|
|
645
918
|
|
|
919
|
+
(Or use `.addHelpCommand()` to add a command you construct yourself.)
|
|
920
|
+
|
|
646
921
|
### More configuration
|
|
647
922
|
|
|
648
923
|
The built-in help is formatted using the Help class.
|
|
@@ -653,12 +928,13 @@ The data properties are:
|
|
|
653
928
|
- `helpWidth`: specify the wrap width, useful for unit tests
|
|
654
929
|
- `sortSubcommands`: sort the subcommands alphabetically
|
|
655
930
|
- `sortOptions`: sort the options alphabetically
|
|
931
|
+
- `showGlobalOptions`: show a section with the global options from the parent command(s)
|
|
656
932
|
|
|
657
|
-
There are methods getting the visible lists of arguments, options, and subcommands. There are methods for formatting the items in the lists, with each item having a _term_ and _description_. Take a look at `.formatHelp()` to see how they are used.
|
|
933
|
+
You can override any method on the [Help](./lib/help.js) class. There are methods getting the visible lists of arguments, options, and subcommands. There are methods for formatting the items in the lists, with each item having a _term_ and _description_. Take a look at `.formatHelp()` to see how they are used.
|
|
658
934
|
|
|
659
935
|
Example file: [configure-help.js](./examples/configure-help.js)
|
|
660
936
|
|
|
661
|
-
```
|
|
937
|
+
```js
|
|
662
938
|
program.configureHelp({
|
|
663
939
|
sortSubcommands: true,
|
|
664
940
|
subcommandTerm: (cmd) => cmd.name() // Just show the name, instead of short usage.
|
|
@@ -673,13 +949,6 @@ You can execute custom actions by listening to command and option events.
|
|
|
673
949
|
program.on('option:verbose', function () {
|
|
674
950
|
process.env.VERBOSE = this.opts().verbose;
|
|
675
951
|
});
|
|
676
|
-
|
|
677
|
-
program.on('command:*', function (operands) {
|
|
678
|
-
console.error(`error: unknown command '${operands[0]}'`);
|
|
679
|
-
const availableCommands = program.commands.map(cmd => cmd.name());
|
|
680
|
-
mySuggestBestMatch(operands[0], availableCommands);
|
|
681
|
-
process.exitCode = 1;
|
|
682
|
-
});
|
|
683
952
|
```
|
|
684
953
|
|
|
685
954
|
## Bits and pieces
|
|
@@ -702,11 +971,13 @@ program.parse(); // Implicit, and auto-detect electron
|
|
|
702
971
|
program.parse(['-f', 'filename'], { from: 'user' });
|
|
703
972
|
```
|
|
704
973
|
|
|
974
|
+
If you want to parse multiple times, create a new program each time. Calling parse does not clear out any previous state.
|
|
975
|
+
|
|
705
976
|
### Parsing Configuration
|
|
706
977
|
|
|
707
978
|
If the default parsing does not suit your needs, there are some behaviours to support other usage patterns.
|
|
708
979
|
|
|
709
|
-
By default program options are recognised before and after subcommands. To only look for program options before subcommands, use `.enablePositionalOptions()`. This lets you use
|
|
980
|
+
By default, program options are recognised before and after subcommands. To only look for program options before subcommands, use `.enablePositionalOptions()`. This lets you use
|
|
710
981
|
an option for a different purpose in subcommands.
|
|
711
982
|
|
|
712
983
|
Example file: [positional-options.js](./examples/positional-options.js)
|
|
@@ -718,9 +989,9 @@ program -b subcommand
|
|
|
718
989
|
program subcommand -b
|
|
719
990
|
```
|
|
720
991
|
|
|
721
|
-
By default options are recognised before and after command-arguments. To only process options that come
|
|
722
|
-
before the command-arguments, use `.passThroughOptions()`. This lets you pass the
|
|
723
|
-
without needing to use `--` to end the option processing.
|
|
992
|
+
By default, options are recognised before and after command-arguments. To only process options that come
|
|
993
|
+
before the command-arguments, use `.passThroughOptions()`. This lets you pass the arguments and following options through to another program
|
|
994
|
+
without needing to use `--` to end the option processing.
|
|
724
995
|
To use pass through options in a subcommand, the program needs to enable positional options.
|
|
725
996
|
|
|
726
997
|
Example file: [pass-through-options.js](./examples/pass-through-options.js)
|
|
@@ -732,15 +1003,15 @@ program --port=80 arg
|
|
|
732
1003
|
program arg --port=80
|
|
733
1004
|
```
|
|
734
1005
|
|
|
735
|
-
By default the option processing shows an error for an unknown option. To have an unknown option treated as an ordinary command-argument and continue looking for options, use `.allowUnknownOption()`. This lets you mix known and unknown options.
|
|
1006
|
+
By default, the option processing shows an error for an unknown option. To have an unknown option treated as an ordinary command-argument and continue looking for options, use `.allowUnknownOption()`. This lets you mix known and unknown options.
|
|
736
1007
|
|
|
737
|
-
By default the argument processing does not display an error for more command-arguments than expected.
|
|
1008
|
+
By default, the argument processing does not display an error for more command-arguments than expected.
|
|
738
1009
|
To display an error for excess arguments, use`.allowExcessArguments(false)`.
|
|
739
1010
|
|
|
740
|
-
### Legacy options as properties
|
|
1011
|
+
### Legacy options as properties
|
|
741
1012
|
|
|
742
1013
|
Before Commander 7, the option values were stored as properties on the command.
|
|
743
|
-
This was convenient to code but the downside was possible clashes with
|
|
1014
|
+
This was convenient to code, but the downside was possible clashes with
|
|
744
1015
|
existing properties of `Command`. You can revert to the old behaviour to run unmodified legacy code by using `.storeOptionsAsProperties()`.
|
|
745
1016
|
|
|
746
1017
|
```js
|
|
@@ -756,9 +1027,17 @@ program
|
|
|
756
1027
|
|
|
757
1028
|
### TypeScript
|
|
758
1029
|
|
|
759
|
-
|
|
1030
|
+
extra-typings: There is an optional project to infer extra type information from the option and argument definitions.
|
|
1031
|
+
This adds strong typing to the options returned by `.opts()` and the parameters to `.action()`.
|
|
1032
|
+
See [commander-js/extra-typings](https://github.com/commander-js/extra-typings) for more.
|
|
1033
|
+
|
|
1034
|
+
```
|
|
1035
|
+
import { Command } from '@commander-js/extra-typings';
|
|
1036
|
+
```
|
|
1037
|
+
|
|
1038
|
+
ts-node: 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.
|
|
760
1039
|
|
|
761
|
-
```
|
|
1040
|
+
```sh
|
|
762
1041
|
node -r ts-node/register pm.ts
|
|
763
1042
|
```
|
|
764
1043
|
|
|
@@ -786,18 +1065,42 @@ You can enable `--harmony` option in two ways:
|
|
|
786
1065
|
|
|
787
1066
|
An executable subcommand is launched as a separate child process.
|
|
788
1067
|
|
|
789
|
-
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
|
|
1068
|
+
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.,
|
|
790
1069
|
the inspector port is incremented by 1 for the spawned subcommand.
|
|
791
1070
|
|
|
792
1071
|
If you are using VSCode to debug executable subcommands you need to set the `"autoAttachChildProcesses": true` flag in your launch.json configuration.
|
|
793
1072
|
|
|
1073
|
+
### npm run-script
|
|
1074
|
+
|
|
1075
|
+
By default, when you call your program using run-script, `npm` will parse any options on the command-line and they will not reach your program. Use
|
|
1076
|
+
`--` to stop the npm option parsing and pass through all the arguments.
|
|
1077
|
+
|
|
1078
|
+
The synopsis for [npm run-script](https://docs.npmjs.com/cli/v9/commands/npm-run-script) explicitly shows the `--` for this reason:
|
|
1079
|
+
|
|
1080
|
+
```console
|
|
1081
|
+
npm run-script <command> [-- <args>]
|
|
1082
|
+
```
|
|
1083
|
+
|
|
1084
|
+
### Display error
|
|
1085
|
+
|
|
1086
|
+
This routine is available to invoke the Commander error handling for your own error conditions. (See also the next section about exit handling.)
|
|
1087
|
+
|
|
1088
|
+
As well as the error message, you can optionally specify the `exitCode` (used with `process.exit`)
|
|
1089
|
+
and `code` (used with `CommanderError`).
|
|
1090
|
+
|
|
1091
|
+
```js
|
|
1092
|
+
program.error('Password must be longer than four characters');
|
|
1093
|
+
program.error('Custom processing has failed', { exitCode: 2, code: 'my.custom.error' });
|
|
1094
|
+
```
|
|
1095
|
+
|
|
794
1096
|
### Override exit and output handling
|
|
795
1097
|
|
|
796
|
-
By default Commander calls `process.exit` when it detects errors, or after displaying the help or version. You can override
|
|
1098
|
+
By default, Commander calls `process.exit` when it detects errors, or after displaying the help or version. You can override
|
|
797
1099
|
this behaviour and optionally supply a callback. The default override throws a `CommanderError`.
|
|
798
1100
|
|
|
799
|
-
The override callback is passed a `CommanderError` with properties `exitCode` number, `code` string, and `message`.
|
|
800
|
-
|
|
1101
|
+
The override callback is passed a `CommanderError` with properties `exitCode` number, `code` string, and `message`.
|
|
1102
|
+
Commander expects the callback to terminate the normal program flow, and will call `process.exit` if the callback returns.
|
|
1103
|
+
The normal display of error messages or version or help is not affected by the override which is called after the display.
|
|
801
1104
|
|
|
802
1105
|
```js
|
|
803
1106
|
program.exitOverride();
|
|
@@ -809,12 +1112,11 @@ try {
|
|
|
809
1112
|
}
|
|
810
1113
|
```
|
|
811
1114
|
|
|
812
|
-
By default Commander is configured for a command-line application and writes to stdout and stderr.
|
|
1115
|
+
By default, Commander is configured for a command-line application and writes to stdout and stderr.
|
|
813
1116
|
You can modify this behaviour for custom applications. In addition, you can modify the display of error messages.
|
|
814
1117
|
|
|
815
1118
|
Example file: [configure-output.js](./examples/configure-output.js)
|
|
816
1119
|
|
|
817
|
-
|
|
818
1120
|
```js
|
|
819
1121
|
function errorColor(str) {
|
|
820
1122
|
// Add ANSI escape codes to display text in red.
|
|
@@ -836,77 +1138,13 @@ program
|
|
|
836
1138
|
There is more information available about:
|
|
837
1139
|
|
|
838
1140
|
- [deprecated](./docs/deprecated.md) features still supported for backwards compatibility
|
|
839
|
-
- [options taking varying arguments](./docs/options-
|
|
840
|
-
|
|
841
|
-
## Examples
|
|
842
|
-
|
|
843
|
-
In a single command program, you might not need an action handler.
|
|
844
|
-
|
|
845
|
-
Example file: [pizza](./examples/pizza)
|
|
846
|
-
|
|
847
|
-
```js
|
|
848
|
-
const { program } = require('commander');
|
|
849
|
-
|
|
850
|
-
program
|
|
851
|
-
.description('An application for pizza ordering')
|
|
852
|
-
.option('-p, --peppers', 'Add peppers')
|
|
853
|
-
.option('-c, --cheese <type>', 'Add the specified type of cheese', 'marble')
|
|
854
|
-
.option('-C, --no-cheese', 'You do not want any cheese');
|
|
855
|
-
|
|
856
|
-
program.parse();
|
|
857
|
-
|
|
858
|
-
const options = program.opts();
|
|
859
|
-
console.log('you ordered a pizza with:');
|
|
860
|
-
if (options.peppers) console.log(' - peppers');
|
|
861
|
-
const cheese = !options.cheese ? 'no' : options.cheese;
|
|
862
|
-
console.log(' - %s cheese', cheese);
|
|
863
|
-
```
|
|
864
|
-
|
|
865
|
-
In a multi-command program, you will have action handlers for each command (or stand-alone executables for the commands).
|
|
866
|
-
|
|
867
|
-
Example file: [deploy](./examples/deploy)
|
|
868
|
-
|
|
869
|
-
```js
|
|
870
|
-
const { Command } = require('commander');
|
|
871
|
-
const program = new Command();
|
|
872
|
-
|
|
873
|
-
program
|
|
874
|
-
.version('0.0.1')
|
|
875
|
-
.option('-c, --config <path>', 'set config path', './deploy.conf');
|
|
876
|
-
|
|
877
|
-
program
|
|
878
|
-
.command('setup [env]')
|
|
879
|
-
.description('run setup commands for all envs')
|
|
880
|
-
.option('-s, --setup_mode <mode>', 'Which setup mode to use', 'normal')
|
|
881
|
-
.action((env, options) => {
|
|
882
|
-
env = env || 'all';
|
|
883
|
-
console.log('read config from %s', program.opts().config);
|
|
884
|
-
console.log('setup for %s env(s) with %s mode', env, options.setup_mode);
|
|
885
|
-
});
|
|
886
|
-
|
|
887
|
-
program
|
|
888
|
-
.command('exec <script>')
|
|
889
|
-
.alias('ex')
|
|
890
|
-
.description('execute the given remote cmd')
|
|
891
|
-
.option('-e, --exec_mode <mode>', 'Which exec mode to use', 'fast')
|
|
892
|
-
.action((script, options) => {
|
|
893
|
-
console.log('read config from %s', program.opts().config);
|
|
894
|
-
console.log('exec "%s" using %s mode and config %s', script, options.exec_mode, program.opts().config);
|
|
895
|
-
}).addHelpText('after', `
|
|
896
|
-
Examples:
|
|
897
|
-
$ deploy exec sequential
|
|
898
|
-
$ deploy exec async`
|
|
899
|
-
);
|
|
900
|
-
|
|
901
|
-
program.parse(process.argv);
|
|
902
|
-
```
|
|
903
|
-
|
|
904
|
-
More samples can be found in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory.
|
|
1141
|
+
- [options taking varying arguments](./docs/options-in-depth.md)
|
|
1142
|
+
- [parsing life cycle and hooks](./docs/parsing-and-hooks.md)
|
|
905
1143
|
|
|
906
1144
|
## Support
|
|
907
1145
|
|
|
908
|
-
The current version of Commander is fully supported on Long Term Support versions of
|
|
909
|
-
(For older versions of
|
|
1146
|
+
The current version of Commander is fully supported on Long Term Support versions of Node.js, and requires at least v18.
|
|
1147
|
+
(For older versions of Node.js, use an older version of Commander.)
|
|
910
1148
|
|
|
911
1149
|
The main forum for free and community support is the project [Issues](https://github.com/tj/commander.js/issues) on GitHub.
|
|
912
1150
|
|