Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit c2fd099

Browse files
committed
At post-install, ask the user to turn on command line autocompletion
1 parent 1687c99 commit c2fd099

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

bootstrap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ $injector.requireCommand(["help", "/?"], "./common/commands/help");
3030
$injector.requireCommand("feature-usage-tracking", "./common/commands/analytics");
3131

3232
$injector.requireCommand("dev-post-install", "./common/commands/post-install");
33+
$injector.requireCommand("autocomplete", "./common/commands/completion-prompt");
3334

3435
$injector.requireCommand("device|*list", "./common/commands/device/list-devices");
3536
$injector.requireCommand("device|android", "./common/commands/device/list-devices");

commands/completion-prompt.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
///<reference path="../../.d.ts"/>
2+
"use strict";
3+
import helpers = require("../helpers");
4+
5+
export class CompletionPromptCommand implements ICommand {
6+
7+
constructor(private $autoCompletionService: IAutoCompletionService,
8+
private $logger: ILogger,
9+
private $prompter: IPrompter) {
10+
}
11+
12+
public disableAnalytics = true;
13+
public allowedParameters: ICommandParameter[] = [];
14+
15+
public execute(args: string[]): IFuture<void> {
16+
return (() => {
17+
if (helpers.isInteractive()) {
18+
this.$logger.out("If you are using bash or zsh, you can enable command line auto completion.");
19+
var message = "Enable it now?";
20+
21+
var autoCompetionStatus = this.$prompter.confirm(message, () => "y").wait();
22+
23+
if (autoCompetionStatus) {
24+
this.$autoCompletionService.enableAutoCompletion().wait();
25+
}
26+
}
27+
}).future<void>()();
28+
}
29+
}
30+
$injector.registerCommand("autocomplete", CompletionPromptCommand);

commands/post-install.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export class PostInstallCommand implements ICommand {
1313
private $fs: IFileSystem,
1414
private $staticConfig: Config.IStaticConfig,
1515
private $childProcess: IChildProcess,
16-
private $errors: IErrors) {
16+
private $errors: IErrors,
17+
private $commandsService: ICommandsService) {
1718
}
1819

1920
public disableAnalytics = true;
@@ -29,8 +30,8 @@ export class PostInstallCommand implements ICommand {
2930
}
3031
}
3132

32-
this.$autoCompletionService.enableAutoCompletion().wait();
3333
this.checkSevenZip().wait();
34+
this.$commandsService.tryExecuteCommand("autocomplete", []).wait();
3435
}).future<void>()();
3536
}
3637

0 commit comments

Comments
 (0)