From 84a72147df35ada2e4d9457123d4102663644a8b Mon Sep 17 00:00:00 2001 From: Umberto Pepato Date: Wed, 23 Sep 2020 19:01:49 +0200 Subject: [PATCH] feat(cli): add bash completions support --- README.md | 15 ++++++++++----- deps.ts | 1 + src/cli/commands/vr.ts | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 52beb5a..6acd82b 100644 --- a/README.md +++ b/README.md @@ -384,8 +384,9 @@ to execute the `start` script. ## Exporting scripts -You may find yourself in a situation where you want to use velociraptor to manage your scripts during development, but you're not comfortable installing it (or just can't install it) in your production environment. -In this case the `export` subcommand may be of help: it allows you to export one or more scripts as standalone executable shell files: +If you want to use velociraptor to manage your scripts, but you want to be able to execute them in environments where +you can't (or don't want to) install vr, the `export` subcommand may be of help: it allows you to export one or more +scripts as standalone executable shell files together with their env variables, Deno cli options etc.: ```sh $ vr export [SCRIPTS]... @@ -402,7 +403,7 @@ For example, run $ vr export start ``` -to export the `start` script, together with its env variables, deno cli options etc. Now you can execute it by running +to export the `start` script. Now you can execute it by running ```sh $ ./bin/start [ARGS]... @@ -422,13 +423,17 @@ Velociraptor searches for script files up the folder tree starting from the dire ## Shell completions -To enable zsh tab-completion for velociraptor commands, add the following line to your `~/.zshrc` +To enable shell tab-completion for velociraptor commands, add the following line to your `~/.zshrc` ```sh source <(vr completions zsh) ``` -> Bash is not supported yet, but will be added. +or `~/.bashrc` + +```sh +source <(vr completions bash) +``` ## Editor support diff --git a/deps.ts b/deps.ts index 58a8391..3a1a087 100644 --- a/deps.ts +++ b/deps.ts @@ -18,4 +18,5 @@ export { LevelName } from "https://deno.land/std@0.70.0/log/levels.ts"; export { Command, StringType, + CompletionsCommand, } from "https://deno.land/x/cliffy@v0.14.1/command/mod.ts"; diff --git a/src/cli/commands/vr.ts b/src/cli/commands/vr.ts index 194c691..659d585 100644 --- a/src/cli/commands/vr.ts +++ b/src/cli/commands/vr.ts @@ -1,4 +1,4 @@ -import { Command } from "../../../deps.ts"; +import { Command, CompletionsCommand } from "../../../deps.ts"; import { version } from "../../version.ts"; import { ScriptIdType } from "../script_id_type.ts"; import { ConfigData } from "../../load_config.ts"; @@ -30,6 +30,7 @@ export class VrCommand extends Command { }) .command("run", new RunCommand(this.configData)) .command("export", new ExportCommand(this.configData)) + .command("completions", new CompletionsCommand()) .reset(); } }