Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: autocomplete for data connector as flag #136

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions pkg/entity/data_connector/cmd.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package data_connector

import (
"fmt"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/strmprivacy/api-definitions-go/v2/api/data_connectors/v1"
"strings"
"strmprivacy/strm/pkg/common"
"strmprivacy/strm/pkg/util"
)
Expand Down Expand Up @@ -83,15 +84,15 @@ func CreateCmd() *cobra.Command {
}

func NamesCompletion(cmd *cobra.Command, args []string, complete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 && strings.Fields(cmd.Short)[0] != "Delete" {
// this one means you don't get multiple completion suggestions for one stream if it's not a delete call
return nil, cobra.ShellCompDirectiveNoFileComp
}
log.Traceln(fmt.Sprintf("cmd: %s, args: %s, cmdShort: %s", cmd.CommandPath(), args))

req := &data_connectors.ListDataConnectorsRequest{
ProjectId: common.ProjectId,
}
response, err := Client.ListDataConnectors(apiContext, req)

log.Traceln(response)

if err != nil {
return common.GrpcRequestCompletionError(err)
}
Expand All @@ -101,5 +102,7 @@ func NamesCompletion(cmd *cobra.Command, args []string, complete string) ([]stri
names = append(names, dataConnector.Ref.Name)
}

log.Traceln(names)

return names, cobra.ShellCompDirectiveNoFileComp
}