diff options
| author | Eyal Posener <[email protected]> | 2017-05-06 18:55:54 +0300 |
|---|---|---|
| committer | Eyal Posener <[email protected]> | 2017-05-06 18:55:54 +0300 |
| commit | 4f47fe9246e715f11272d6323343a12797d4d13f (patch) | |
| tree | 65eb8cd82bbb5da33c548b5510f91f8017b04330 /run.go | |
| parent | d33bac720bcaf13a5ee9f6f165293183d2e3e24d (diff) | |
Add easy way to install the bash completion
Diffstat (limited to 'run.go')
| -rw-r--r-- | run.go | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -14,7 +14,11 @@ const ( // Run get a command, get the typed arguments from environment // variable, and print out the complete options func Run(c Command) { - args := getLine() + args, ok := getLine() + if !ok { + runCommandLine(c.Name) + return + } Log("Completing args: %s", args) options := complete(c, args) @@ -38,12 +42,12 @@ func complete(c Command, args []string) (matching []string) { return } -func getLine() []string { +func getLine() ([]string, bool) { line := os.Getenv(envComplete) if line == "" { - panic("should be run as a complete script") + return nil, false } - return strings.Split(line, " ") + return strings.Split(line, " "), true } func last(args []string) (last string) { |
