// RegisterNameFlagCompletionFunc adds dynamic completion for the --name flag
RegisterNameFlagCompletionFunc adds dynamic completion for the --name flag
// RegisterNameFlagCompletionFunc adds dynamic completion for the -- name flag
func RegisterNameFlagCompletionFunc(cmd *cobra.Command, f *factory.Factory) error {
	return cmd.RegisterFlagCompletionFunc("name", func(cmd *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		var validNames []string
		directive := cobra.ShellCompDirectiveNoSpace
		conn, err := f.Connection(connection.DefaultConfigSkipMasAuth)
		if err != nil {
			return validNames, directive
		}
		req := conn.API().KafkaMgmt().GetKafkas(f.Context)
		if toComplete != "" {
			searchQ := "name like " + toComplete + "%"
			req = req.Search(searchQ)
		}
		kafkas, httpRes, err := req.Execute()
		if err != nil {
			return validNames, directive
		}
		if httpRes != nil {
			defer httpRes.Body.Close()
		}
		items := kafkas.GetItems()
		for index := range items {
			validNames = append(validNames, items[index].GetName())
		}
		return validNames, directive
	})
}
func RegisterNameFlagCompletionFunc ( cmd * cobra . Command , f * factory . Factory ) error { return cmd . RegisterFlagCompletionFunc ( " " , func ( cmd * cobra . Command , _ [ ] string , toComplete string ) ( [ ] string , cobra . ShellCompDirective ) { var validNames [ ] string directive := cobra . ShellCompDirectiveNoSpace conn , err := f . Connection ( connection . DefaultConfigSkipMasAuth ) if err != nil { return validNames , directive } req := conn . API ( ) . KafkaMgmt ( ) . GetKafkas ( f . Context ) if toComplete != " " { searchQ := " " + toComplete + " " req = req . Search ( searchQ ) } kafkas , httpRes , err := req . Execute ( ) if err != nil { return validNames , directive } if httpRes != nil { defer httpRes . Body . Close ( ) } items := kafkas . GetItems ( ) for index := range items { validNames = append ( validNames , items [ index ] . GetName ( ) ) } return validNames , directive } ) }
RegisterNameFlagCompletionFunc adds dynamic completion for the --name flag
RegisterNameFlagCompletionFunc adds dynamic completion for the -- name flag