Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Further clarify magic comment for completions

  • Loading branch information...
commit 3b1bbfc2df61adca9d94047b7cccd5efe844a5c3 1 parent 6ff0580
@qrush qrush authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 README.md
View
8 README.md
@@ -118,7 +118,11 @@ Your sub loves autocompletion. It's the mustard, mayo, or whatever topping you'd
1. Automatic autocompletion to find subcommands (What can this sub do?)
2. Opt-in autocompletion of potential arguments for your subcommands (What can this subcommand do?)
-Opting into autocompletion of subcommands requires that you add a magic comment, and then support parsing of a flag: `--complete`. Here's an example from rbenv, namely `rbenv whence`:
+Opting into autocompletion of subcommands requires that you add a magic comment of (make sure to replace with your sub's name!):
+
+ # Provide YOUR_SUB_NAME completions
+
+and then your script must support parsing of a flag: `--complete`. Here's an example from rbenv, namely `rbenv whence`:
``` bash
#!/usr/bin/env bash
@@ -134,8 +138,6 @@ fi
# lots more bash...
```
-The magic comment looks like `# Provide your_sub_name completions`
-
Passing the `--complete` flag to this subcommand short circuits the real command, and then runs another subcommand instead. The output from your subcommand's `--complete` run is sent to your shell's autocompletion handler for you, and you don't ever have to once worry about how any of that works!
Run the `init` subcommand after you've prepared your sub to get your sub loading automatically in your shell.
Please sign in to comment.
Something went wrong with that request. Please try again.