Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cdf750081e |
+11
-5
@@ -199,12 +199,18 @@ func rootCmd() *cobra.Command {
|
||||
}
|
||||
c := cache.New(cfg.Cache.Path, cfg.Cache.TTL)
|
||||
_ = c.Load()
|
||||
entries := c.Search(toComplete)
|
||||
names := make([]cobra.Completion, len(entries))
|
||||
for i, e := range entries {
|
||||
names[i] = cobra.Completion(e.Name)
|
||||
|
||||
var completions []cobra.Completion
|
||||
for _, e := range c.Search(toComplete) {
|
||||
completions = append(completions, cobra.Completion(e.Name))
|
||||
}
|
||||
return names, cobra.ShellCompDirectiveNoFileComp
|
||||
// Subcommands at the end, after all hostnames.
|
||||
for _, sub := range cmd.Commands() {
|
||||
if sub.IsAvailableCommand() && strings.HasPrefix(sub.Name(), toComplete) {
|
||||
completions = append(completions, cobra.Completion(sub.Name()+"\t"+sub.Short))
|
||||
}
|
||||
}
|
||||
return completions, cobra.ShellCompDirectiveNoFileComp | cobra.ShellCompDirectiveKeepOrder
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user