mirror of
https://github.com/psviderski/uncloud.git
synced 2026-10-06 21:29:02 +00:00
fix(cli): completion with direct connections (--connect, --context, --uncloud-config) (fixes #377)
This commit is contained in:
1 parent
fa77edf53e
commit
351698c280
6 files changed
+159
-4
No files matched your search
@@ -11,6 +11,11 @@ import (
|
||||
)
|
||||
|
||||
func Contexts(ctx context.Context, uncli *cli.CLI, args []string, toComplete string) ([]cobra.Completion, cobra.ShellCompDirective) {
|
||||
// There are no contexts to complete when the CLI uses a direct machine connection (--connect) without a config.
|
||||
if uncli.Config == nil {
|
||||
return nil, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
contexts := slices.Sorted(maps.Keys(uncli.Config.Contexts))
|
||||
|
||||
names := []cobra.Completion{}
|
||||
@@ -21,7 +26,6 @@ func Contexts(ctx context.Context, uncli *cli.CLI, args []string, toComplete str
|
||||
if strings.HasPrefix(context, toComplete) {
|
||||
names = append(names, context)
|
||||
}
|
||||
names = append(names, context)
|
||||
}
|
||||
|
||||
return names, cobra.ShellCompDirectiveNoFileComp
|
||||
|
||||
Reference in new issue
Block a user