nuxt-ai-ready 2.5.0 → 2.5.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.
- package/dist/chunks/agent-skills.mjs +1 -1
- package/dist/chunks/prerender.mjs +1 -1
- package/dist/cli.mjs +2 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/server/db/drizzle/queries.js +0 -1
- package/dist/runtime/server/db/queries.d.ts +2 -0
- package/dist/runtime/server/db/queries.js +11 -5
- package/dist/runtime/server/db/seed.d.ts +2 -2
- package/dist/runtime/server/routes/__ai-ready/reindex.post.js +2 -0
- package/dist/runtime/server/utils/batchIndex.js +4 -2
- package/dist/runtime/server/utils/checkStale.d.ts +1 -1
- package/dist/runtime/server/utils/checkStale.js +1 -1
- package/dist/runtime/server/utils/indexPage.d.ts +8 -1
- package/dist/runtime/server/utils/indexPage.js +13 -5
- package/dist/shared/{nuxt-ai-ready.DsokNmXc.mjs → nuxt-ai-ready.CLSWou20.mjs} +2 -0
- package/node_modules/@mdream/js/LICENSE.md +9 -0
- package/node_modules/@mdream/js/README.md +792 -0
- package/node_modules/@mdream/js/bin/mdream.mjs +2 -0
- package/node_modules/@mdream/js/dist/_chunks/const.mjs +134 -0
- package/node_modules/@mdream/js/dist/_chunks/index.d.mts +9 -0
- package/node_modules/@mdream/js/dist/_chunks/markdown-processor.mjs +1968 -0
- package/node_modules/@mdream/js/dist/_chunks/minimal.d.mts +6 -0
- package/node_modules/@mdream/js/dist/_chunks/parse.mjs +2756 -0
- package/node_modules/@mdream/js/dist/_chunks/plugins.mjs +725 -0
- package/node_modules/@mdream/js/dist/_chunks/resolve-plugins.mjs +44 -0
- package/node_modules/@mdream/js/dist/_chunks/stream.mjs +37 -0
- package/node_modules/@mdream/js/dist/_chunks/types.d.mts +473 -0
- package/node_modules/@mdream/js/dist/cli.d.mts +1 -0
- package/node_modules/@mdream/js/dist/cli.mjs +32 -0
- package/node_modules/@mdream/js/dist/core.d.mts +15 -0
- package/node_modules/@mdream/js/dist/core.mjs +28 -0
- package/node_modules/@mdream/js/dist/index.d.mts +4 -0
- package/node_modules/@mdream/js/dist/index.mjs +58 -0
- package/node_modules/@mdream/js/dist/llms-txt.d.mts +86 -0
- package/node_modules/@mdream/js/dist/llms-txt.mjs +308 -0
- package/node_modules/@mdream/js/dist/negotiate.d.mts +35 -0
- package/node_modules/@mdream/js/dist/negotiate.mjs +121 -0
- package/node_modules/@mdream/js/dist/parse.d.mts +90 -0
- package/node_modules/@mdream/js/dist/parse.mjs +2 -0
- package/node_modules/@mdream/js/dist/plugins.d.mts +85 -0
- package/node_modules/@mdream/js/dist/plugins.mjs +2 -0
- package/node_modules/@mdream/js/dist/preset/minimal.d.mts +2 -0
- package/node_modules/@mdream/js/dist/preset/minimal.mjs +33 -0
- package/node_modules/@mdream/js/dist/splitter.d.mts +18 -0
- package/node_modules/@mdream/js/dist/splitter.mjs +194 -0
- package/node_modules/@mdream/js/package.json +103 -0
- package/node_modules/cac/LICENSE +21 -0
- package/node_modules/cac/README.md +492 -0
- package/node_modules/cac/dist/index.d.ts +196 -0
- package/node_modules/cac/dist/index.js +638 -0
- package/node_modules/cac/package.json +72 -0
- package/node_modules/mdream/LICENSE.md +9 -0
- package/node_modules/mdream/README.md +1091 -0
- package/node_modules/mdream/bin/mdream.mjs +46 -0
- package/node_modules/mdream/dist/browser.d.mts +105 -0
- package/node_modules/mdream/dist/browser.mjs +262 -0
- package/node_modules/mdream/dist/edge.d.mts +100 -0
- package/node_modules/mdream/dist/edge.mjs +250 -0
- package/node_modules/mdream/dist/iife.js +605 -0
- package/node_modules/mdream/dist/index.d.mts +89 -0
- package/node_modules/mdream/dist/index.mjs +184 -0
- package/node_modules/mdream/dist/wasm.d.mts +100 -0
- package/node_modules/mdream/dist/wasm.mjs +140 -0
- package/node_modules/mdream/dist/worker.d.mts +101 -0
- package/node_modules/mdream/dist/worker.mjs +217 -0
- package/node_modules/mdream/napi/index.d.mts +127 -0
- package/node_modules/mdream/napi/index.d.ts +127 -0
- package/node_modules/mdream/napi/index.mjs +725 -0
- package/node_modules/mdream/napi/rust.android-arm-eabi.node +0 -0
- package/node_modules/mdream/napi/rust.android-arm64.node +0 -0
- package/node_modules/mdream/napi/rust.darwin-arm64.node +0 -0
- package/node_modules/mdream/napi/rust.darwin-x64.node +0 -0
- package/node_modules/mdream/napi/rust.freebsd-x64.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm-gnueabihf.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm64-gnu.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm64-musl.node +0 -0
- package/node_modules/mdream/napi/rust.linux-x64-gnu.node +0 -0
- package/node_modules/mdream/napi/rust.linux-x64-musl.node +0 -0
- package/node_modules/mdream/napi/rust.wasi.cjs +2144 -0
- package/node_modules/mdream/napi/rust.wasm32-wasi.wasm +0 -0
- package/node_modules/mdream/napi/rust.win32-arm64-msvc.node +0 -0
- package/node_modules/mdream/napi/rust.win32-x64-msvc.node +0 -0
- package/node_modules/mdream/node_modules/@emnapi/core/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@emnapi/core/README.md +1 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.d.ts +392 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.d.ts +392 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.js +8351 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.js +7268 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.d.ts +5 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.js +843 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.d.ts +4 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.js +3 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.d.ts +5 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.js +1010 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.d.ts +5 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.js +1446 -0
- package/node_modules/mdream/node_modules/@emnapi/core/package.json +39 -0
- package/node_modules/mdream/node_modules/@emnapi/core/rollup.config.js +60 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/README.md +1 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.d.ts +833 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js +2306 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js.map +1 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/index.cjs +63 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/package.json +39 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/rollup.config.js +25 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/README.md +203 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +236 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +1086 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/package.json +35 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/rollup.config.js +6 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.cjs +1472 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.js +1470 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +237 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs.js +18260 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +317 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/package.json +67 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.cjs +39 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.js +36 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/README.md +193 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/tsdoc-metadata.json +11 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +423 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +2932 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +2932 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.js +2954 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/asyncify.js +158 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/index.js +13 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/jspi.js +46 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/load.js +97 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/memory.js +35 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/error.js +103 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fd.js +268 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fs.js +3 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +192 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +316 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +1599 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/rights.js +141 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/types.js +220 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/util.js +128 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/webassembly.js +13 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/asyncify.mjs +153 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/index.mjs +9 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/jspi.mjs +39 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/load.mjs +89 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/memory.mjs +28 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/error.mjs +97 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fd.mjs +256 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fs.mjs +1 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +186 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +310 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +1593 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/rights.mjs +135 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/types.mjs +216 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/util.mjs +113 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/webassembly.mjs +9 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/package.json +58 -0
- package/node_modules/mdream/node_modules/tslib/CopyrightNotice.txt +15 -0
- package/node_modules/mdream/node_modules/tslib/LICENSE.txt +12 -0
- package/node_modules/mdream/node_modules/tslib/README.md +164 -0
- package/node_modules/mdream/node_modules/tslib/SECURITY.md +41 -0
- package/node_modules/mdream/node_modules/tslib/modules/index.d.ts +38 -0
- package/node_modules/mdream/node_modules/tslib/modules/index.js +70 -0
- package/node_modules/mdream/node_modules/tslib/modules/package.json +3 -0
- package/node_modules/mdream/node_modules/tslib/package.json +47 -0
- package/node_modules/mdream/node_modules/tslib/tslib.d.ts +460 -0
- package/node_modules/mdream/node_modules/tslib/tslib.es6.html +1 -0
- package/node_modules/mdream/node_modules/tslib/tslib.es6.js +402 -0
- package/node_modules/mdream/node_modules/tslib/tslib.es6.mjs +401 -0
- package/node_modules/mdream/node_modules/tslib/tslib.html +1 -0
- package/node_modules/mdream/node_modules/tslib/tslib.js +484 -0
- package/node_modules/mdream/package.json +110 -0
- package/node_modules/mdream/skills/mdream/SKILL.md +124 -0
- package/node_modules/mdream/skills/mdream/references/runtimes.md +49 -0
- package/node_modules/mdream/wasm/mdream_edge.d.ts +90 -0
- package/node_modules/mdream/wasm/mdream_edge.js +517 -0
- package/node_modules/mdream/wasm/mdream_edge_bg.wasm +0 -0
- package/node_modules/mdream/wasm/mdream_edge_bg.wasm.d.ts +20 -0
- package/node_modules/mdream/wasm/package.json +17 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge.d.ts +45 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge.js +13 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.js +413 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm +0 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm.d.ts +20 -0
- package/node_modules/mdream/wasm-bundler/package.json +19 -0
- package/node_modules/pathe/LICENSE +70 -0
- package/node_modules/pathe/README.md +73 -0
- package/node_modules/pathe/dist/index.cjs +39 -0
- package/node_modules/pathe/dist/index.d.cts +47 -0
- package/node_modules/pathe/dist/index.d.mts +47 -0
- package/node_modules/pathe/dist/index.d.ts +47 -0
- package/node_modules/pathe/dist/index.mjs +19 -0
- package/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs +266 -0
- package/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +249 -0
- package/node_modules/pathe/dist/utils.cjs +82 -0
- package/node_modules/pathe/dist/utils.d.cts +32 -0
- package/node_modules/pathe/dist/utils.d.mts +32 -0
- package/node_modules/pathe/dist/utils.d.ts +32 -0
- package/node_modules/pathe/dist/utils.mjs +77 -0
- package/node_modules/pathe/package.json +61 -0
- package/node_modules/pathe/utils.d.ts +1 -0
- package/package.json +8 -64
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
<img width="945" alt="2017-07-26 9 27 05" src="https://user-images.githubusercontent.com/8784712/28623641-373450f4-7249-11e7-854d-1b076dab274d.png">
|
|
2
|
+
|
|
3
|
+
[](https://npmx.dev/package/cac) [](https://npmx.dev/package/cac) [](https://circleci.com/gh/cacjs/cac/tree/master) [](https://codecov.io/gh/cacjs/cac) [](https://github.com/egoist/donate) [](https://packagephobia.now.sh/result?p=cac)
|
|
4
|
+
|
|
5
|
+
## Introduction
|
|
6
|
+
|
|
7
|
+
**C**ommand **A**nd **C**onquer is a JavaScript library for building CLI apps.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Super light-weight**: No dependency, just a single file.
|
|
12
|
+
- **Easy to learn**. There're only 4 APIs you need to learn for building simple CLIs: `cli.option` `cli.version` `cli.help` `cli.parse`.
|
|
13
|
+
- **Yet so powerful**. Enable features like default command, git-like subcommands, validation for required arguments and options, variadic arguments, dot-nested options, automated help message generation and so on.
|
|
14
|
+
- **Developer friendly**. Written in TypeScript.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm i cac
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Simple Parsing
|
|
25
|
+
|
|
26
|
+
Use CAC as simple argument parser:
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
// examples/basic-usage.js
|
|
30
|
+
import cac from 'cac'
|
|
31
|
+
const cli = cac()
|
|
32
|
+
|
|
33
|
+
cli.option('--type <type>', 'Choose a project type', {
|
|
34
|
+
default: 'node',
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const parsed = cli.parse()
|
|
38
|
+
|
|
39
|
+
console.log(JSON.stringify(parsed, null, 2))
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
<img width="500" alt="2018-11-26 12 28 03" src="https://user-images.githubusercontent.com/8784712/48981576-2a871000-f112-11e8-8151-80f61e9b9908.png">
|
|
43
|
+
|
|
44
|
+
### Display Help Message and Version
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
// examples/help.js
|
|
48
|
+
import cac from 'cac'
|
|
49
|
+
const cli = cac()
|
|
50
|
+
|
|
51
|
+
cli.option('--type [type]', 'Choose a project type', {
|
|
52
|
+
default: 'node',
|
|
53
|
+
})
|
|
54
|
+
cli.option('--name <name>', 'Provide your name')
|
|
55
|
+
|
|
56
|
+
cli.command('lint [...files]', 'Lint files').action((files, options) => {
|
|
57
|
+
console.log(files, options)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
// Display help message when `-h` or `--help` appears
|
|
61
|
+
cli.help()
|
|
62
|
+
// Display version number when `-v` or `--version` appears
|
|
63
|
+
// It's also used in help message
|
|
64
|
+
cli.version('0.0.0')
|
|
65
|
+
|
|
66
|
+
cli.parse()
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
<img width="500" alt="2018-11-25 8 21 14" src="https://user-images.githubusercontent.com/8784712/48979012-acb20d00-f0ef-11e8-9cc6-8ffca00ab78a.png">
|
|
70
|
+
|
|
71
|
+
### Command-specific Options
|
|
72
|
+
|
|
73
|
+
You can attach options to a command.
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
import cac from 'cac'
|
|
77
|
+
const cli = cac()
|
|
78
|
+
|
|
79
|
+
cli
|
|
80
|
+
.command('rm <dir>', 'Remove a dir')
|
|
81
|
+
.option('-r, --recursive', 'Remove recursively')
|
|
82
|
+
.action((dir, options) => {
|
|
83
|
+
console.log(`remove ${dir}${options.recursive ? ' recursively' : ''}`)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
cli.help()
|
|
87
|
+
|
|
88
|
+
cli.parse()
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
A command's options are validated when the command is used. Any unknown options will be reported as an error. However, if an action-based command does not define an action, then the options are not validated. If you really want to use unknown options, use [`command.allowUnknownOptions`](#commandallowunknownoptions).
|
|
92
|
+
|
|
93
|
+
<img alt="command options" width="500" src="https://user-images.githubusercontent.com/8784712/49065552-49dc8500-f259-11e8-9c7b-a7c32d70920e.png">
|
|
94
|
+
|
|
95
|
+
### Dash in option names
|
|
96
|
+
|
|
97
|
+
Options in kebab-case should be referenced in camelCase in your code:
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
cli
|
|
101
|
+
.command('dev', 'Start dev server')
|
|
102
|
+
.option('--clear-screen', 'Clear screen')
|
|
103
|
+
.action((options) => {
|
|
104
|
+
console.log(options.clearScreen)
|
|
105
|
+
})
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
In fact `--clear-screen` and `--clearScreen` are both mapped to `options.clearScreen`.
|
|
109
|
+
|
|
110
|
+
### Brackets
|
|
111
|
+
|
|
112
|
+
When using brackets in command name, angled brackets indicate required command arguments, while square bracket indicate optional arguments.
|
|
113
|
+
|
|
114
|
+
When using brackets in option name, angled brackets indicate that a string / number value is required, while square bracket indicate that the value can also be `true`.
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
import cac from 'cac'
|
|
118
|
+
const cli = cac()
|
|
119
|
+
|
|
120
|
+
cli
|
|
121
|
+
.command('deploy <folder>', 'Deploy a folder to AWS')
|
|
122
|
+
.option('--scale [level]', 'Scaling level')
|
|
123
|
+
.action((folder, options) => {
|
|
124
|
+
// ...
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
cli
|
|
128
|
+
.command('build [project]', 'Build a project')
|
|
129
|
+
.option('--out <dir>', 'Output directory')
|
|
130
|
+
.action((folder, options) => {
|
|
131
|
+
// ...
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
cli.parse()
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Negated Options
|
|
138
|
+
|
|
139
|
+
To allow an option whose value is `false`, you need to manually specify a negated option:
|
|
140
|
+
|
|
141
|
+
```js
|
|
142
|
+
cli
|
|
143
|
+
.command('build [project]', 'Build a project')
|
|
144
|
+
.option('--no-config', 'Disable config file')
|
|
145
|
+
.option('--config <path>', 'Use a custom config file')
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
This will let CAC set the default value of `config` to true, and you can use `--no-config` flag to set it to `false`.
|
|
149
|
+
|
|
150
|
+
### Variadic Arguments
|
|
151
|
+
|
|
152
|
+
The last argument of a command can be variadic, and only the last argument. To make an argument variadic you have to add `...` to the start of argument name, just like the rest operator in JavaScript. Here is an example:
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
import cac from 'cac'
|
|
156
|
+
const cli = cac()
|
|
157
|
+
|
|
158
|
+
cli
|
|
159
|
+
.command('build <entry> [...otherFiles]', 'Build your app')
|
|
160
|
+
.option('--foo', 'Foo option')
|
|
161
|
+
.action((entry, otherFiles, options) => {
|
|
162
|
+
console.log(entry)
|
|
163
|
+
console.log(otherFiles)
|
|
164
|
+
console.log(options)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
cli.help()
|
|
168
|
+
|
|
169
|
+
cli.parse()
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
<img width="500" alt="2018-11-25 8 25 30" src="https://user-images.githubusercontent.com/8784712/48979056-47125080-f0f0-11e8-9d8f-3219e0beb0ed.png">
|
|
173
|
+
|
|
174
|
+
### Dot-nested Options
|
|
175
|
+
|
|
176
|
+
Dot-nested options will be merged into a single option.
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
import cac from 'cac'
|
|
180
|
+
const cli = cac()
|
|
181
|
+
|
|
182
|
+
cli
|
|
183
|
+
.command('build', 'desc')
|
|
184
|
+
.option('--env <env>', 'Set envs')
|
|
185
|
+
.example('--env.API_SECRET xxx')
|
|
186
|
+
.action((options) => {
|
|
187
|
+
console.log(options)
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
cli.help()
|
|
191
|
+
|
|
192
|
+
cli.parse()
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
<img width="500" alt="2018-11-25 9 37 53" src="https://user-images.githubusercontent.com/8784712/48979771-6ada9400-f0fa-11e8-8192-e541b2cfd9da.png">
|
|
196
|
+
|
|
197
|
+
### Default Command
|
|
198
|
+
|
|
199
|
+
Register a command that will be used when no other command is matched.
|
|
200
|
+
|
|
201
|
+
```js
|
|
202
|
+
import cac from 'cac'
|
|
203
|
+
const cli = cac()
|
|
204
|
+
|
|
205
|
+
cli
|
|
206
|
+
// Simply omit the command name, just brackets
|
|
207
|
+
.command('[...files]', 'Build files')
|
|
208
|
+
.option('--minimize', 'Minimize output')
|
|
209
|
+
.action((files, options) => {
|
|
210
|
+
console.log(files)
|
|
211
|
+
console.log(options.minimize)
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
cli.parse()
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Supply an array as option value
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
node cli.js --include project-a
|
|
221
|
+
# The parsed options will be:
|
|
222
|
+
# { include: 'project-a' }
|
|
223
|
+
|
|
224
|
+
node cli.js --include project-a --include project-b
|
|
225
|
+
# The parsed options will be:
|
|
226
|
+
# { include: ['project-a', 'project-b'] }
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Error Handling
|
|
230
|
+
|
|
231
|
+
To handle command errors globally:
|
|
232
|
+
|
|
233
|
+
```js
|
|
234
|
+
try {
|
|
235
|
+
// Parse CLI args without running the command
|
|
236
|
+
cli.parse(process.argv, { run: false })
|
|
237
|
+
// Run the command yourself
|
|
238
|
+
// You only need `await` when your command action returns a Promise
|
|
239
|
+
await cli.runMatchedCommand()
|
|
240
|
+
} catch (error) {
|
|
241
|
+
// Handle error here..
|
|
242
|
+
// e.g.
|
|
243
|
+
console.error(error.stack)
|
|
244
|
+
process.exit(1)
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### With TypeScript
|
|
249
|
+
|
|
250
|
+
First you need `@types/node` to be installed as a dev dependency in your project:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
npm i @types/node --dev
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Then everything just works out of the box:
|
|
257
|
+
|
|
258
|
+
```js
|
|
259
|
+
import { cac } from 'cac'
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### With Deno
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
import { cac } from 'jsr:@cac/cac'
|
|
266
|
+
|
|
267
|
+
const cli = cac('my-program')
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Projects Using CAC
|
|
271
|
+
|
|
272
|
+
Projects that use **CAC**:
|
|
273
|
+
|
|
274
|
+
- [Vite](https://github.com/vitejs/vite): ⚡️ Next generation frontend tooling. It's fast!
|
|
275
|
+
- [Vitest](https://github.com/vitest-dev/vitest) - Next generation testing framework powered by Vite.
|
|
276
|
+
- [tsdown](https://github.com/rolldown/tsdown) - The elegant bundler for libraries powered by Rolldown.
|
|
277
|
+
- [VuePress](https://github.com/vuejs/vuepress): :memo: Minimalistic Vue-powered static site generator.
|
|
278
|
+
- [DocPad](https://github.com/docpad/docpad): 🏹 Powerful Static Site Generator.
|
|
279
|
+
- [bili](https://github.com/egoist/bili): 🥂 Schweizer Armeemesser for bundling JavaScript libraries.
|
|
280
|
+
- [Lad](https://github.com/ladjs/lad): 👦 Lad scaffolds a Koa webapp and API framework for Node.js.
|
|
281
|
+
- [Lass](https://github.com/lassjs/lass): 💁🏻 Scaffold a modern package boilerplate for Node.js.
|
|
282
|
+
- [Foy](https://github.com/zaaack/foy): 🏗 A lightweight and modern task runner and build tool for general purpose.
|
|
283
|
+
- [Vuese](https://github.com/vuese/vuese): 🤗 One-stop solution for vue component documentation.
|
|
284
|
+
- [NUT](https://github.com/nut-project/nut): 🌰 A framework born for microfrontends.
|
|
285
|
+
- [Taze](https://github.com/antfu-collective/taze): 🥦 A modern cli tool that keeps your deps fresh.
|
|
286
|
+
- Feel free to add yours here...
|
|
287
|
+
|
|
288
|
+
## References
|
|
289
|
+
|
|
290
|
+
**💁 Check out [API reference](https://npmx.dev/package-docs/cac) from source code if you want a more in-depth API references.**
|
|
291
|
+
|
|
292
|
+
Below is a brief overview.
|
|
293
|
+
|
|
294
|
+
### CLI Instance
|
|
295
|
+
|
|
296
|
+
CLI instance is created by invoking the `cac` function:
|
|
297
|
+
|
|
298
|
+
```js
|
|
299
|
+
import cac from 'cac'
|
|
300
|
+
const cli = cac()
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
#### cac(name?)
|
|
304
|
+
|
|
305
|
+
Create a CLI instance, optionally specify the program name which will be used to display in help and version message. When not set we use the basename of `argv[1]`.
|
|
306
|
+
|
|
307
|
+
#### cli.command(name, description, config?)
|
|
308
|
+
|
|
309
|
+
- Type: `(name: string, description: string) => Command`
|
|
310
|
+
|
|
311
|
+
Create a command instance.
|
|
312
|
+
|
|
313
|
+
The option also accepts a third argument `config` for additional command config:
|
|
314
|
+
|
|
315
|
+
- `config.allowUnknownOptions`: `boolean` Allow unknown options in this command.
|
|
316
|
+
- `config.ignoreOptionDefaultValue`: `boolean` Don't use the options's default value in parsed options, only display them in help message.
|
|
317
|
+
|
|
318
|
+
#### cli.option(name, description, config?)
|
|
319
|
+
|
|
320
|
+
- Type: `(name: string, description: string, config?: OptionConfig) => CLI`
|
|
321
|
+
|
|
322
|
+
Add a global option.
|
|
323
|
+
|
|
324
|
+
The option also accepts a third argument `config` for additional option config:
|
|
325
|
+
|
|
326
|
+
- `config.default`: Default value for the option.
|
|
327
|
+
- `config.type`: `any[]` When set to `[]`, the option value returns an array type. You can also use a conversion function such as `[String]`, which will invoke the option value with `String`.
|
|
328
|
+
|
|
329
|
+
#### cli.parse(argv?)
|
|
330
|
+
|
|
331
|
+
- Type: `(argv = process.argv) => ParsedArgv`
|
|
332
|
+
|
|
333
|
+
```ts
|
|
334
|
+
interface ParsedArgv {
|
|
335
|
+
args: string[]
|
|
336
|
+
options: {
|
|
337
|
+
[k: string]: any
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
When this method is called, `cli.rawArgs` `cli.args` `cli.options` `cli.matchedCommand` will also be available.
|
|
343
|
+
|
|
344
|
+
#### cli.version(version, customFlags?)
|
|
345
|
+
|
|
346
|
+
- Type: `(version: string, customFlags = '-v, --version') => CLI`
|
|
347
|
+
|
|
348
|
+
Output version number when `-v, --version` flag appears.
|
|
349
|
+
|
|
350
|
+
#### cli.help(callback?)
|
|
351
|
+
|
|
352
|
+
- Type: `(callback?: HelpCallback) => CLI`
|
|
353
|
+
|
|
354
|
+
Output help message when `-h, --help` flag appears.
|
|
355
|
+
|
|
356
|
+
Optional `callback` allows post-processing of help text before it is displayed:
|
|
357
|
+
|
|
358
|
+
```ts
|
|
359
|
+
type HelpCallback = (sections: HelpSection[]) => void
|
|
360
|
+
|
|
361
|
+
interface HelpSection {
|
|
362
|
+
title?: string
|
|
363
|
+
body: string
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
#### cli.outputHelp()
|
|
368
|
+
|
|
369
|
+
- Type: `() => CLI`
|
|
370
|
+
|
|
371
|
+
Output help message.
|
|
372
|
+
|
|
373
|
+
#### cli.usage(text)
|
|
374
|
+
|
|
375
|
+
- Type: `(text: string) => CLI`
|
|
376
|
+
|
|
377
|
+
Add a global usage text. This is not used by sub-commands.
|
|
378
|
+
|
|
379
|
+
### Command Instance
|
|
380
|
+
|
|
381
|
+
Command instance is created by invoking the `cli.command` method:
|
|
382
|
+
|
|
383
|
+
```js
|
|
384
|
+
const command = cli.command('build [...files]', 'Build given files')
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
#### command.option()
|
|
388
|
+
|
|
389
|
+
Basically the same as `cli.option` but this adds the option to specific command.
|
|
390
|
+
|
|
391
|
+
#### command.action(callback)
|
|
392
|
+
|
|
393
|
+
- Type: `(callback: ActionCallback) => Command`
|
|
394
|
+
|
|
395
|
+
Use a callback function as the command action when the command matches user inputs.
|
|
396
|
+
|
|
397
|
+
```ts
|
|
398
|
+
type ActionCallback = (
|
|
399
|
+
// Parsed CLI args
|
|
400
|
+
// The last arg will be an array if it's a variadic argument
|
|
401
|
+
...args: string | string[] | number | number[],
|
|
402
|
+
// Parsed CLI options
|
|
403
|
+
options: Options
|
|
404
|
+
) => any
|
|
405
|
+
|
|
406
|
+
interface Options {
|
|
407
|
+
[k: string]: any
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
#### command.alias(name)
|
|
412
|
+
|
|
413
|
+
- Type: `(name: string) => Command`
|
|
414
|
+
|
|
415
|
+
Add an alias name to this command, the `name` here can't contain brackets.
|
|
416
|
+
|
|
417
|
+
#### command.allowUnknownOptions()
|
|
418
|
+
|
|
419
|
+
- Type: `() => Command`
|
|
420
|
+
|
|
421
|
+
Allow unknown options in this command, by default CAC will log an error when unknown options are used.
|
|
422
|
+
|
|
423
|
+
#### command.example(example)
|
|
424
|
+
|
|
425
|
+
- Type: `(example: CommandExample) => Command`
|
|
426
|
+
|
|
427
|
+
Add an example which will be displayed at the end of help message.
|
|
428
|
+
|
|
429
|
+
```ts
|
|
430
|
+
type CommandExample = ((name: string) => string) | string
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
#### command.usage(text)
|
|
434
|
+
|
|
435
|
+
- Type: `(text: string) => Command`
|
|
436
|
+
|
|
437
|
+
Add a usage text for this command.
|
|
438
|
+
|
|
439
|
+
### Events
|
|
440
|
+
|
|
441
|
+
Listen to commands:
|
|
442
|
+
|
|
443
|
+
```js
|
|
444
|
+
// Listen to the `foo` command
|
|
445
|
+
cli.addEventListener('command:foo', () => {
|
|
446
|
+
// Do something
|
|
447
|
+
})
|
|
448
|
+
|
|
449
|
+
// Listen to the default command
|
|
450
|
+
cli.addEventListener('command:!', () => {
|
|
451
|
+
// Do something
|
|
452
|
+
})
|
|
453
|
+
|
|
454
|
+
// Listen to unknown commands
|
|
455
|
+
cli.addEventListener('command:*', () => {
|
|
456
|
+
console.error('Invalid command: %s', cli.args.join(' '))
|
|
457
|
+
process.exit(1)
|
|
458
|
+
})
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
## FAQ
|
|
462
|
+
|
|
463
|
+
### How is the name written and pronounced?
|
|
464
|
+
|
|
465
|
+
CAC, or cac, pronounced `C-A-C`.
|
|
466
|
+
|
|
467
|
+
This project is dedicated to our lovely C.C. sama. Maybe CAC stands for C&C as well :P
|
|
468
|
+
|
|
469
|
+
<img src="http://i.giphy.com/v3FeH4swox9mg.gif" width="400"/>
|
|
470
|
+
|
|
471
|
+
### Why not use Commander.js?
|
|
472
|
+
|
|
473
|
+
CAC is very similar to Commander.js, while the latter does not support dot nested options, i.e. something like `--env.API_SECRET foo`. Besides, you can't use unknown options in Commander.js either.
|
|
474
|
+
|
|
475
|
+
_And maybe more..._
|
|
476
|
+
|
|
477
|
+
Basically I made CAC to fulfill my own needs for building CLI apps like [Poi](https://poi.js.org), [SAO](https://sao.vercel.app) and all my CLI apps. It's small, simple but powerful :P
|
|
478
|
+
|
|
479
|
+
## Contributing
|
|
480
|
+
|
|
481
|
+
1. Fork it!
|
|
482
|
+
2. Create your feature branch: `git checkout -b my-new-feature`
|
|
483
|
+
3. Commit your changes: `git commit -am 'Add some feature'`
|
|
484
|
+
4. Push to the branch: `git push origin my-new-feature`
|
|
485
|
+
5. Submit a pull request :D
|
|
486
|
+
|
|
487
|
+
## Author
|
|
488
|
+
|
|
489
|
+
**CAC** © [EGOIST](https://github.com/egoist), Released under the [MIT](./LICENSE) License.<br>
|
|
490
|
+
Authored and maintained by egoist with help from contributors ([list](https://github.com/cacjs/cac/contributors)).
|
|
491
|
+
|
|
492
|
+
> [Website](https://egoist.dev) · GitHub [@egoist](https://github.com/egoist) · Twitter [@\_egoistlily](https://twitter.com/_egoistlily)
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
//#region src/option.d.ts
|
|
2
|
+
interface OptionConfig {
|
|
3
|
+
default?: any;
|
|
4
|
+
type?: any[];
|
|
5
|
+
}
|
|
6
|
+
declare class Option {
|
|
7
|
+
rawName: string;
|
|
8
|
+
description: string;
|
|
9
|
+
/** Option name */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Option name and aliases */
|
|
12
|
+
names: string[];
|
|
13
|
+
isBoolean?: boolean;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
config: OptionConfig;
|
|
16
|
+
negated: boolean;
|
|
17
|
+
constructor(rawName: string, description: string, config?: OptionConfig);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/command.d.ts
|
|
21
|
+
interface CommandArg {
|
|
22
|
+
required: boolean;
|
|
23
|
+
value: string;
|
|
24
|
+
variadic: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface HelpSection {
|
|
27
|
+
title?: string;
|
|
28
|
+
body: string;
|
|
29
|
+
}
|
|
30
|
+
interface CommandConfig {
|
|
31
|
+
allowUnknownOptions?: boolean;
|
|
32
|
+
ignoreOptionDefaultValue?: boolean;
|
|
33
|
+
}
|
|
34
|
+
type HelpCallback = (sections: HelpSection[]) => void | HelpSection[];
|
|
35
|
+
type CommandExample = ((bin: string) => string) | string;
|
|
36
|
+
declare class Command {
|
|
37
|
+
rawName: string;
|
|
38
|
+
description: string;
|
|
39
|
+
config: CommandConfig;
|
|
40
|
+
cli: CAC;
|
|
41
|
+
options: Option[];
|
|
42
|
+
aliasNames: string[];
|
|
43
|
+
name: string;
|
|
44
|
+
args: CommandArg[];
|
|
45
|
+
commandAction?: (...args: any[]) => any;
|
|
46
|
+
usageText?: string;
|
|
47
|
+
versionNumber?: string;
|
|
48
|
+
examples: CommandExample[];
|
|
49
|
+
helpCallback?: HelpCallback;
|
|
50
|
+
globalCommand?: GlobalCommand;
|
|
51
|
+
constructor(rawName: string, description: string, config: CommandConfig | undefined, cli: CAC);
|
|
52
|
+
usage(text: string): this;
|
|
53
|
+
allowUnknownOptions(): this;
|
|
54
|
+
ignoreOptionDefaultValue(): this;
|
|
55
|
+
version(version: string, customFlags?: string): this;
|
|
56
|
+
example(example: CommandExample): this;
|
|
57
|
+
/**
|
|
58
|
+
* Add a option for this command
|
|
59
|
+
* @param rawName Raw option name(s)
|
|
60
|
+
* @param description Option description
|
|
61
|
+
* @param config Option config
|
|
62
|
+
*/
|
|
63
|
+
option(rawName: string, description: string, config?: OptionConfig): this;
|
|
64
|
+
alias(name: string): this;
|
|
65
|
+
action(callback: (...args: any[]) => any): this;
|
|
66
|
+
/**
|
|
67
|
+
* Check if a command name is matched by this command
|
|
68
|
+
* @param name Command name
|
|
69
|
+
*/
|
|
70
|
+
isMatched(name: string): boolean;
|
|
71
|
+
get isDefaultCommand(): boolean;
|
|
72
|
+
get isGlobalCommand(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Check if an option is registered in this command
|
|
75
|
+
* @param name Option name
|
|
76
|
+
*/
|
|
77
|
+
hasOption(name: string): Option | undefined;
|
|
78
|
+
outputHelp(): void;
|
|
79
|
+
outputVersion(): void;
|
|
80
|
+
checkRequiredArgs(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Check if the parsed options contain any unknown options
|
|
83
|
+
*
|
|
84
|
+
* Exit and output error when true
|
|
85
|
+
*/
|
|
86
|
+
checkUnknownOptions(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Check if the required string-type options exist
|
|
89
|
+
*/
|
|
90
|
+
checkOptionValue(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Check if the number of args is more than expected
|
|
93
|
+
*/
|
|
94
|
+
checkUnusedArgs(): void;
|
|
95
|
+
}
|
|
96
|
+
declare class GlobalCommand extends Command {
|
|
97
|
+
constructor(cli: CAC);
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/cac.d.ts
|
|
101
|
+
interface ParsedArgv {
|
|
102
|
+
args: ReadonlyArray<string>;
|
|
103
|
+
options: {
|
|
104
|
+
[k: string]: any;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
declare class CAC extends EventTarget {
|
|
108
|
+
/** The program name to display in help and version message */
|
|
109
|
+
name: string;
|
|
110
|
+
commands: Command[];
|
|
111
|
+
globalCommand: GlobalCommand;
|
|
112
|
+
matchedCommand?: Command;
|
|
113
|
+
matchedCommandName?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Raw CLI arguments
|
|
116
|
+
*/
|
|
117
|
+
rawArgs: string[];
|
|
118
|
+
/**
|
|
119
|
+
* Parsed CLI arguments
|
|
120
|
+
*/
|
|
121
|
+
args: ParsedArgv["args"];
|
|
122
|
+
/**
|
|
123
|
+
* Parsed CLI options, camelCased
|
|
124
|
+
*/
|
|
125
|
+
options: ParsedArgv["options"];
|
|
126
|
+
showHelpOnExit?: boolean;
|
|
127
|
+
showVersionOnExit?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* @param name The program name to display in help and version message
|
|
130
|
+
*/
|
|
131
|
+
constructor(name?: string);
|
|
132
|
+
/**
|
|
133
|
+
* Add a global usage text.
|
|
134
|
+
*
|
|
135
|
+
* This is not used by sub-commands.
|
|
136
|
+
*/
|
|
137
|
+
usage(text: string): this;
|
|
138
|
+
/**
|
|
139
|
+
* Add a sub-command
|
|
140
|
+
*/
|
|
141
|
+
command(rawName: string, description?: string, config?: CommandConfig): Command;
|
|
142
|
+
/**
|
|
143
|
+
* Add a global CLI option.
|
|
144
|
+
*
|
|
145
|
+
* Which is also applied to sub-commands.
|
|
146
|
+
*/
|
|
147
|
+
option(rawName: string, description: string, config?: OptionConfig): this;
|
|
148
|
+
/**
|
|
149
|
+
* Show help message when `-h, --help` flags appear.
|
|
150
|
+
*
|
|
151
|
+
*/
|
|
152
|
+
help(callback?: HelpCallback): this;
|
|
153
|
+
/**
|
|
154
|
+
* Show version number when `-v, --version` flags appear.
|
|
155
|
+
*
|
|
156
|
+
*/
|
|
157
|
+
version(version: string, customFlags?: string): this;
|
|
158
|
+
/**
|
|
159
|
+
* Add a global example.
|
|
160
|
+
*
|
|
161
|
+
* This example added here will not be used by sub-commands.
|
|
162
|
+
*/
|
|
163
|
+
example(example: CommandExample): this;
|
|
164
|
+
/**
|
|
165
|
+
* Output the corresponding help message
|
|
166
|
+
* When a sub-command is matched, output the help message for the command
|
|
167
|
+
* Otherwise output the global one.
|
|
168
|
+
*
|
|
169
|
+
*/
|
|
170
|
+
outputHelp(): void;
|
|
171
|
+
/**
|
|
172
|
+
* Output the version number.
|
|
173
|
+
*
|
|
174
|
+
*/
|
|
175
|
+
outputVersion(): void;
|
|
176
|
+
private setParsedInfo;
|
|
177
|
+
unsetMatchedCommand(): void;
|
|
178
|
+
/**
|
|
179
|
+
* Parse argv
|
|
180
|
+
*/
|
|
181
|
+
parse(argv?: string[], {
|
|
182
|
+
run
|
|
183
|
+
}?: {
|
|
184
|
+
/** Whether to run the action for matched command */run?: boolean | undefined;
|
|
185
|
+
}): ParsedArgv;
|
|
186
|
+
private mri;
|
|
187
|
+
runMatchedCommand(): any;
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/index.d.ts
|
|
191
|
+
/**
|
|
192
|
+
* @param name The program name to display in help and version message
|
|
193
|
+
*/
|
|
194
|
+
declare const cac: (name?: string) => CAC;
|
|
195
|
+
//#endregion
|
|
196
|
+
export { CAC, Command, cac, cac as default };
|