-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
44 lines (33 loc) · 1.08 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
import { CompletionBase } from '../../base'
import { getInstructionsForBash } from '../../utils/bash'
import { getInstructionsForFish } from '../../utils/fish'
import { getInstructionsForZsh } from '../../utils/zsh'
export default class Completion extends CompletionBase {
static description = [
`Generate shell completion script`,
``,
`Run this command to see instructions for your shell.`,
].join('\n')
static args = []
static flags = {
...CompletionBase.flags,
}
static examples = ['$ <%= config.bin %> completion --shell zsh']
async run() {
const { flags } = this.parse(Completion)
const shell = flags.shell
const aliases = this.aliases
const { bin } = this.config
let instructions: string[] = []
if (shell === 'bash') {
instructions = getInstructionsForBash({ bin, shell, aliases })
}
if (shell === 'fish') {
instructions = getInstructionsForFish({ bin, shell, aliases })
}
if (shell === 'zsh') {
instructions = getInstructionsForZsh({ bin, shell })
}
this.log(instructions.join('\n'))
}
}