-
Notifications
You must be signed in to change notification settings - Fork 0
/
autocomplete.ts
42 lines (36 loc) · 1.07 KB
/
autocomplete.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
import {Command, flags} from '@oclif/command'
import * as fs from "fs";
import * as path from "path";
export default class ListProj extends Command {
static description = "Install completion file";
static examples = [
`$ td autocomplete --zsh ~/.zsh_completion`
];
static flags = {
help: flags.help({ char: 'h' }),
zsh: flags.boolean({
description: "Install zsh completion"
})
};
static args = [{
name: "dir",
description: "Install completion files to specific directory",
required: true
}];
async run() {
const { flags, args } = this.parse(ListProj);
try {
if (flags.zsh) {
const target = path.join(args.dir, "_td");
fs.copyFileSync(path.join(__dirname, "../../autocomplete/_td"), target);
this.log(`Completion file installed to ${target}.\nMake sure ${args.dir} is in $fpath environment.\nStart a new zsh shell to put it into effect.`);
}
else {
this.error("Shell flag required. See --help for details");
}
}
catch (error) {
this.error(error);
}
}
}