This commit is contained in:
Eyal Posener 2017-05-06 22:25:44 +03:00
parent c26ef096c7
commit cc743aad8b
3 changed files with 12 additions and 2 deletions

View File

@ -10,6 +10,10 @@ type installer interface {
Uninstall(cmd, bin string) error
}
// Install complete command given:
// cmd: is the command name
// asRoot: if true the completion will be installed in /etc/bash_complete.d
// otherwise the complete command will be added to the ~/.bashrc file.
func Install(cmd string, asRoot bool) error {
bin, err := getBinaryPath()
if err != nil {
@ -18,6 +22,10 @@ func Install(cmd string, asRoot bool) error {
return getInstaller(asRoot).Install(cmd, bin)
}
// Uninstall complete command given:
// cmd: is the command name
// asRoot: if true the completion will be removed from /etc/bash_complete.d
// otherwise the complete command will be removed from the ~/.bashrc file.
func Uninstall(cmd string, asRoot bool) error {
bin, err := getBinaryPath()
if err != nil {

View File

@ -20,6 +20,7 @@ func (a MatchPrefix) String() string {
return string(a)
}
// Match returns true if a has the prefix as prefix
func (a MatchPrefix) Match(prefix string) bool {
return strings.HasPrefix(string(a), prefix)
}
@ -32,6 +33,7 @@ func (a MatchFileName) String() string {
return string(a)
}
// Match returns true if prefix's abs path prefixes a's abs path
func (a MatchFileName) Match(prefix string) bool {
full, err := filepath.Abs(string(a))
if err != nil {

View File

@ -27,9 +27,9 @@ func (p Predicate) predict(last string) []Matcher {
}
// PredictNothing does not expect anything after.
var PredictNothing Predicate = nil
var PredictNothing Predicate
// PredictNothing expects something, but nothing particular, such as a number
// PredictAnything expects something, but nothing particular, such as a number
// or arbitrary name.
func PredictAnything(last string) []Matcher { return nil }