Skip to content

Commit

Permalink
fix: autocomplete for data connector as flag (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
trietsch authored Aug 4, 2023
1 parent 49b9270 commit 8ded383
Showing 1 changed file with 8 additions and 5 deletions.
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 @@ -84,15 +85,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 @@ -102,5 +103,7 @@ func NamesCompletion(cmd *cobra.Command, args []string, complete string) ([]stri
names = append(names, dataConnector.Ref.Name)
}

log.Traceln(names)

return names, cobra.ShellCompDirectiveNoFileComp
}

0 comments on commit 8ded383

Please sign in to comment.