]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/autocomplete.go
Merge pull request #1125 from nabeelomer/master
[micro.git] / cmd / micro / autocomplete.go
index 8599c9ae7de142a631d21278633751b1a27efa08..3ecc3f16569bf300612b95561e0cf6f3dffd7552 100644 (file)
@@ -142,6 +142,7 @@ func OptionComplete(input string) (string, []string) {
        return chosen, suggestions
 }
 
+// OptionValueComplete completes values for various options
 func OptionValueComplete(inputOpt, input string) (string, []string) {
        inputOpt = strings.TrimSpace(inputOpt)
        var suggestions []string
@@ -181,6 +182,13 @@ func OptionValueComplete(inputOpt, input string) (string, []string) {
                        if strings.HasPrefix("dos", input) {
                                suggestions = append(suggestions, "dos")
                        }
+               case "sucmd":
+                       if strings.HasPrefix("sudo", input) {
+                               suggestions = append(suggestions, "sudo")
+                       }
+                       if strings.HasPrefix("doas", input) {
+                               suggestions = append(suggestions, "doas")
+                       }
                }
        }
 
@@ -212,6 +220,7 @@ func PluginComplete(complete Completion, input string) (chosen string, suggestio
        return
 }
 
+// PluginCmdComplete completes with possible choices for the `> plugin` command
 func PluginCmdComplete(input string) (chosen string, suggestions []string) {
        for _, cmd := range []string{"install", "remove", "search", "update", "list"} {
                if strings.HasPrefix(cmd, input) {
@@ -225,6 +234,7 @@ func PluginCmdComplete(input string) (chosen string, suggestions []string) {
        return chosen, suggestions
 }
 
+// PluginnameComplete completes with the names of loaded plugins
 func PluginNameComplete(input string) (chosen string, suggestions []string) {
        for _, pp := range GetAllPluginPackages() {
                if strings.HasPrefix(pp.Name, input) {