Documentation
¶
Index ¶
- Variables
- func ChainPositionalArgs(fns ...cobra.PositionalArgs) cobra.PositionalArgs
- func DefaultCompletion(cmd *cobra.Command)
- func InheritRootPersistenPreRun(cmd *cobra.Command)
- func NoCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)
- func PopulateFromArgs(f *Factory, ss ...*string) cobra.PositionalArgs
- type CompletionFunc
- type Factory
- type FlagError
- type RunFunc
- func ChainRunFuncs(fns ...RunFunc) RunFunc
- func NeedsActiveDeployment(f *Factory) RunFunc
- func NeedsDatasets(f *Factory) RunFunc
- func NeedsDeployments(f *Factory) RunFunc
- func NeedsPersonalAccessToken(f *Factory) RunFunc
- func NeedsRootPersistentPreRunE() RunFunc
- func NeedsValidDeployment(f *Factory, alias *string) RunFunc
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSilent is an error that triggers a non zero exit code without any // error message. ErrSilent = errors.New("ErrSilent") // ErrNoPromptArgRequired is raised when the application is not running // interactively and thus requires an argument on the command-line instead // of prompting for input. ErrNoPromptArgRequired = errors.New("argument required when not running interactively") )
Functions ¶
func ChainPositionalArgs ¶
func ChainPositionalArgs(fns ...cobra.PositionalArgs) cobra.PositionalArgs
ChainPositionalArgs chains one or more cobra.PositionalArgs functions.
func DefaultCompletion ¶
DefaultCompletion sets default values for Args and ValidArgsFunction on all child commands. If Args is nil it is set to cobra.NoArgs, if ValidArgsFunction is nil and no ValidArgs are given, it is set to NoCompletion.
func InheritRootPersistenPreRun ¶
InheritRootPersistenPreRun inherits the root commands PersistenPreRunE function down to child commands which specify their own one by chaining them.
func NoCompletion ¶
func NoCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)
NoCompletion disables completion.
func PopulateFromArgs ¶
func PopulateFromArgs(f *Factory, ss ...*string) cobra.PositionalArgs
PopulateFromArgs populates the given values with the argumetns given on the command-line. It returns an error if the application is not running interactively and has not enough arguments to populate all the given values. It applies cobra.MaximumNArgs() with n being the amount of values to populate.
Types ¶
type CompletionFunc ¶
type CompletionFunc func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)
A CompletionFunc is dynamically invoked without running any of the Run() methods on the cobra.Command. Keep this in mind when implementing the, since not all factories are initialized.
func DatasetCompletionFunc ¶
func DatasetCompletionFunc(f *Factory) CompletionFunc
DatasetCompletionFunc returns a completion function which completes the datasets from the configured deployment.
func OrganizationCompletionFunc ¶ added in v0.2.0
func OrganizationCompletionFunc(f *Factory) CompletionFunc
OrganizationCompletionFunc returns a completion function which completes the organization IDs for the active deployment.
type Factory ¶
type Factory struct { // Config is the configuration. Config *config.Config // IO is the IO to be used instead of StdIn, StdOut and StdErr. IO *terminal.IO }
Factory bundles resources used by most commands.
type FlagError ¶
type FlagError struct {
// contains filtered or unexported fields
}
A FlagError is raised when flag processing fails.
func NewFlagError ¶
NewFlagError returns a new *FlagError wrapping the given error.
func NewFlagErrorf ¶
NewFlagErrorf returns a new, formatted *FlagError from the given format and arguments.
type RunFunc ¶
RunFunc is a cobra run function which is compatible with PersistentPreRunE, PreRunE, RunE, PostRunE and PersistentPostRunE.
func ChainRunFuncs ¶
ChainRunFuncs chains one or more RunFunc's.
func NeedsActiveDeployment ¶
NeedsActiveDeployment makes sure an active deployment is configured. If not, it asks for one when the application is running interactively. If no deployments are configured or the application is not running interactively, an error is printed and a silent error returned.
func NeedsDatasets ¶
NeedsDatasets prints an error message and errors silently if no datasets are available on the configured deployment.
func NeedsDeployments ¶
NeedsDeployments prints an error message and errors silently if no deployments are configured.
func NeedsPersonalAccessToken ¶ added in v0.1.6
NeedsPersonalAccessToken prints an error message and errors silently if the active deployment is not configured with a personal access token.
func NeedsRootPersistentPreRunE ¶
func NeedsRootPersistentPreRunE() RunFunc
NeedsRootPersistentPreRunE executes the root commands PersistentPreRunE function.
func NeedsValidDeployment ¶
NeedsValidDeployment prints an error message and errors silently if the given deployment is not configured. An empty alias is not evaluated.