-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathautocompletion.ts
88 lines (75 loc) · 3.01 KB
/
autocompletion.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import * as helpers from "../helpers";
export class AutoCompleteCommand implements ICommand {
constructor(private $autoCompletionService: IAutoCompletionService,
private $logger: ILogger,
private $prompter: IPrompter) {
}
public disableAnalytics = true;
public allowedParameters: ICommandParameter[] = [];
public async execute(args: string[]): Promise<void> {
if (helpers.isInteractive()) {
if (this.$autoCompletionService.isAutoCompletionEnabled()) {
if (this.$autoCompletionService.isObsoleteAutoCompletionEnabled()) {
// obsolete autocompletion is enabled, update it to the new one:
await this.$autoCompletionService.enableAutoCompletion();
} else {
this.$logger.info("Autocompletion is already enabled");
}
} else {
this.$logger.info("If you are using bash or zsh, you can enable command-line completion.");
const message = "Do you want to enable it now?";
const autoCompetionStatus = await this.$prompter.confirm(message, () => true);
if (autoCompetionStatus) {
await this.$autoCompletionService.enableAutoCompletion();
} else {
// make sure we've removed all autocompletion code from all shell profiles
this.$autoCompletionService.disableAutoCompletion();
}
}
}
}
}
$injector.registerCommand("autocomplete|*default", AutoCompleteCommand);
export class DisableAutoCompleteCommand implements ICommand {
constructor(private $autoCompletionService: IAutoCompletionService,
private $logger: ILogger) {
}
public disableAnalytics = true;
public allowedParameters: ICommandParameter[] = [];
public async execute(args: string[]): Promise<void> {
if (this.$autoCompletionService.isAutoCompletionEnabled()) {
this.$autoCompletionService.disableAutoCompletion();
} else {
this.$logger.info("Autocompletion is already disabled.");
}
}
}
$injector.registerCommand("autocomplete|disable", DisableAutoCompleteCommand);
export class EnableAutoCompleteCommand implements ICommand {
constructor(private $autoCompletionService: IAutoCompletionService,
private $logger: ILogger) { }
public disableAnalytics = true;
public allowedParameters: ICommandParameter[] = [];
public async execute(args: string[]): Promise<void> {
if (this.$autoCompletionService.isAutoCompletionEnabled()) {
this.$logger.info("Autocompletion is already enabled.");
} else {
await this.$autoCompletionService.enableAutoCompletion();
}
}
}
$injector.registerCommand("autocomplete|enable", EnableAutoCompleteCommand);
export class AutoCompleteStatusCommand implements ICommand {
constructor(private $autoCompletionService: IAutoCompletionService,
private $logger: ILogger) { }
public disableAnalytics = true;
public allowedParameters: ICommandParameter[] = [];
public async execute(args: string[]): Promise<void> {
if (this.$autoCompletionService.isAutoCompletionEnabled()) {
this.$logger.info("Autocompletion is enabled.");
} else {
this.$logger.info("Autocompletion is disabled.");
}
}
}
$injector.registerCommand("autocomplete|status", AutoCompleteStatusCommand);