completion

package
v0.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2018 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) {
	completions = make([]string, 0)

	applications, err := application.List(context.Client)
	if err != nil {
		return completions
	}

	for _, app := range applications {
		completions = append(completions, app.Name)
	}
	return
}

AppCompletionHandler provides completion for the app commands

View Source
var FileCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) {
	completions = append(completions, complete.PredictFiles("*").Predict(args.original)...)
	return
}

FileCompletionHandler provides suggestions for files and directories

View Source
var ProjectNameCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) {
	completions = make([]string, 0)
	projects, err := project.List(context.Client)
	if err != nil {
		return completions
	}

	for _, project := range projects {

		if val, ok := args.commands[project.Name]; ok && val {
			return nil
		}
		completions = append(completions, project.Name)
	}
	return completions
}

ProjectNameCompletionHandler provides project name completion

View Source
var ServiceClassCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) {
	completions = make([]string, 0)
	services, err := context.Client.GetClusterServiceClasses()
	if err != nil {
		return completions
	}

	for _, class := range services {
		completions = append(completions, class.Spec.ExternalName)
	}

	return
}

ServiceClassCompletionHandler provides catalog service class name completion

View Source
var ServiceCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) {
	completions = make([]string, 0)

	services, err := service.List(context.Client, context.Application)
	if err != nil {
		return completions
	}

	for _, class := range services {
		completions = append(completions, class.Name)
	}

	return
}

ServiceCompletionHandler provides service name completion for the current project and application

View Source
var URLCompletionHandler = func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) (completions []string) {
	completions = make([]string, 0)

	urls, err := url.List(context.Client, context.Component(), context.Application)
	if err != nil {
		return completions
	}

	for _, url := range urls {

		if val, ok := args.commands[url.Name]; ok && val {
			return nil
		}
		completions = append(completions, url.Name)
	}
	return
}

URLCompletionHandler provides completion for the url commands

Functions

func GetCommandFlagHandler

func GetCommandFlagHandler(command *cobra.Command, flag string) (predictor complete.Predictor, ok bool)

GetCommandFlagHandler retrieves the command handler associated with the specified flag of the specified command or nil otherwise

func GetCommandHandler

func GetCommandHandler(command *cobra.Command) (predictor complete.Predictor, ok bool)

GetCommandHandler retrieves the command handler associated with the specified command or nil otherwise

func NewParsedArgs added in v0.0.16

func NewParsedArgs(args complete.Args, cmd *cobra.Command) parsedArgs

NewParsedArgs creates a parsed representation of the provided arguments for the specified command. Mostly exposed for tests.

func RegisterCommandFlagHandler

func RegisterCommandFlagHandler(command *cobra.Command, flag string, predictor ContextualizedPredictor)

RegisterCommandFlagHandler registers the provided ContextualizedPredictor as a completion handler for the specified flag of the specified command

func RegisterCommandHandler

func RegisterCommandHandler(command *cobra.Command, predictor ContextualizedPredictor)

RegisterCommandHandler registers the provided ContextualizedPredictor as a completion handler for the specified command

Types

type ContextualizedPredictor

type ContextualizedPredictor func(cmd *cobra.Command, args parsedArgs, context *genericclioptions.Context) []string

ContextualizedPredictor predicts completion based on specified arguments, potentially using the context provided by the specified client to resolve the entities to be completed

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL