-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
56 lines (45 loc) · 1.31 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { CompletionBase } from '../../../base'
import { generateCompletionScriptForBash } from '../../../utils/bash'
import { generateCompletionScriptForFish } from '../../../utils/fish'
import { generateCompletionScriptForZsh } from '../../../utils/zsh'
export default class CompletionGenerate extends CompletionBase {
static description = [
`Generates completion script`,
``,
`Run the "completion" command to see instructions about how to use the script generated by this command.`,
].join('\n')
static args = []
static flags = {
...CompletionBase.flags,
}
static examples = ['$ <%= config.bin %> completion:generate --shell zsh']
async run() {
const { flags } = this.parse(CompletionGenerate)
const shell = flags.shell
const aliases = this.aliases
const { bin, commands } = this.config
let scriptContent = ''
if (shell === 'bash') {
scriptContent = generateCompletionScriptForBash({
bin,
aliases,
commands,
})
}
if (shell === 'fish') {
scriptContent = generateCompletionScriptForFish({
bin,
aliases,
commands,
})
}
if (shell === 'zsh') {
scriptContent = generateCompletionScriptForZsh({
bin,
aliases,
commands,
})
}
this.log(scriptContent)
}
}