parent
bae3fd94da
commit
1a4c871bd8
17
complete.go
17
complete.go
|
@ -6,6 +6,7 @@
|
||||||
package complete
|
package complete
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -36,11 +37,21 @@ func New(name string, command Command) *Complete {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run get a command, get the typed arguments from environment
|
// Run runs the completion and add installation flags beforehand.
|
||||||
// variable, and print out the complete options
|
// The flags are added to the main flag CommandLine variable.
|
||||||
|
func (c *Complete) Run() bool {
|
||||||
|
c.AddFlags(nil)
|
||||||
|
flag.Parse()
|
||||||
|
return c.Complete()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Complete a command from completion line in environment variable,
|
||||||
|
// and print out the complete options.
|
||||||
// returns success if the completion ran or if the cli matched
|
// returns success if the completion ran or if the cli matched
|
||||||
// any of the given flags, false otherwise
|
// any of the given flags, false otherwise
|
||||||
func (c *Complete) Run() bool {
|
// For installation: it assumes that flags were added and parsed before
|
||||||
|
// it was called.
|
||||||
|
func (c *Complete) Complete() bool {
|
||||||
line, ok := getLine()
|
line, ok := getLine()
|
||||||
if !ok {
|
if !ok {
|
||||||
// make sure flags parsed,
|
// make sure flags parsed,
|
||||||
|
|
Loading…
Reference in New Issue