diff options
| author | Eyal Posener <[email protected]> | 2017-11-04 11:20:50 +0200 |
|---|---|---|
| committer | Eyal Posener <[email protected]> | 2017-11-04 11:32:33 +0200 |
| commit | aae7e1e39fb3554591e2d20b4c86fea9bf2b15bc (patch) | |
| tree | f9a8fe2a68d6e28755a3ef8fc6b73f99a06d5574 /complete.go | |
| parent | 88e59760adaddb8276c9b15511302890690e2dae (diff) | |
Add logic to complete when last flag uses the equal sign
If the last flag is of the form -flag=value, complete the value according to -flag.
Diffstat (limited to 'complete.go')
| -rw-r--r-- | complete.go | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/complete.go b/complete.go index 1df6617..d7b6bf4 100644 --- a/complete.go +++ b/complete.go @@ -9,7 +9,6 @@ import ( "flag" "fmt" "os" - "strings" "github.com/posener/complete/cmd" ) @@ -61,7 +60,7 @@ func (c *Complete) Complete() bool { Log("Completing line: %s", line) a := newArgs(line) - + Log("Completing last field: %s", a.Last) options := c.Command.Predict(a) Log("Completion: %s", options) @@ -69,12 +68,12 @@ func (c *Complete) Complete() bool { return true } -func getLine() ([]string, bool) { +func getLine() (string, bool) { line := os.Getenv(envComplete) if line == "" { - return nil, false + return "", false } - return strings.Split(line, " "), true + return line, true } func output(options []string) { |
