Documentation
¶
Overview ¶
shell is disabled on freebsd as current version of github.com/pkg/term@v1.1.0 is not compiling
Index ¶
- Constants
- Variables
- func ApplyDefaultValues(ctx context.Context, argSpecs ArgSpecs, rawArgs args.RawArgs) args.RawArgs
- func AutoCompleteArgValue(ctx context.Context, cmd *Command, argSpec *ArgSpec, argValuePrefix string) []string
- func Bootstrap(config *BootstrapConfig) (exitCode int, result interface{}, err error)
- func ExecCmd(ctx context.Context, cmd *exec.Cmd) (exitCode int, err error)
- func ExtractBinaryName(ctx context.Context) string
- func ExtractCacheDir(ctx context.Context) string
- func ExtractClient(ctx context.Context) *scw.Client
- func ExtractConfigPath(ctx context.Context) string
- func ExtractConfigPathFlag(ctx context.Context) string
- func ExtractEnv(ctx context.Context, envKey string) string
- func ExtractHTTPClient(ctx context.Context) *http.Client
- func ExtractProfileFlag(ctx context.Context) string
- func ExtractProfileName(ctx context.Context) string
- func ExtractStdin(ctx context.Context) io.Reader
- func ExtractUserHomeDir(ctx context.Context) string
- func GetDocGenContext() context.Context
- func GetOrganizationIDFromContext(ctx context.Context) string
- func GetProjectIDFromContext(ctx context.Context) string
- func GetRandomName(prefix string) string
- func ReloadClient(ctx context.Context) error
- func RunShell(ctx context.Context, printer *Printer, meta *meta, rootCmd *cobra.Command, ...)
- func Test(config *TestConfig) func(t *testing.T)
- type AfterFunc
- type AfterFuncCtx
- type ArgSpec
- type ArgSpecValidateFunc
- type ArgSpecs
- type AutoCompleteArgFunc
- type AutoCompleteNode
- type AutoCompleteNodeType
- type AutocompleteResponse
- type AutocompleteSuggestions
- type BeforeFunc
- func BeforeFuncCombine(beforeFuncs ...BeforeFunc) BeforeFunc
- func BeforeFuncOsExec(cmd string, args ...string) BeforeFunc
- func BeforeFuncStoreInMeta(key string, value interface{}) BeforeFunc
- func BeforeFuncWhenUpdatingCassette(beforeFunc BeforeFunc) BeforeFunc
- func ExecBeforeCmd(cmd string) BeforeFunc
- func ExecStoreBeforeCmd(metaKey, cmd string) BeforeFunc
- type BeforeFuncCtx
- type BootstrapConfig
- type BuildInfo
- type CheckFuncCtx
- type CliError
- func ArgumentConflictError(arg1 string, arg2 string) *CliError
- func InvalidAccessKeyError(value string) *CliError
- func InvalidOrganizationIDError(value string) *CliError
- func InvalidProjectIDError(value string) *CliError
- func InvalidSecretKeyError(value string) *CliError
- func InvalidValueForEnumError(argSpecName string, argSpecEnumValues []string, value string) *CliError
- func MissingRequiredArgumentError(argumentName string) *CliError
- func WindowIsNotSupportedError() *CliError
- type Command
- type CommandInterceptor
- type CommandPreValidateFunc
- type CommandRunner
- type CommandValidateFunc
- type Commands
- func (c *Commands) Add(cmd *Command)
- func (c *Commands) GetAll() []*Command
- func (c *Commands) GetSortedCommand() []*Command
- func (c *Commands) HasSubCommands(cmd *Command) bool
- func (c *Commands) Merge(cmds *Commands)
- func (c *Commands) MustFind(path ...string) *Command
- func (c *Commands) Remove(namespace, verb string)
- type Completer
- type DefaultFunc
- type Example
- type ExecFuncCtx
- type FlagSpec
- type Logger
- func (l *Logger) Debug(args ...interface{})
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Info(args ...interface{})
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) ShouldLog(level logger.LogLevel) bool
- func (l *Logger) Warning(args ...interface{})
- func (l *Logger) Warningf(format string, args ...interface{})
- type MultiResults
- type OverrideExecFunc
- type OverrideExecTestFunc
- type Printer
- type PrinterConfig
- type PrinterType
- type RawResult
- type SeeAlso
- type ShellSuggestion
- type SuccessResult
- type TestCheck
- type TestConfig
- type View
- type ViewField
- type ViewSection
- type WaitFunc
Constants ¶
const ( // PrinterTypeJSON defines a JSON formatter. PrinterTypeJSON = PrinterType("json") // PrinterTypeYAML defines a YAML formatter. PrinterTypeYAML = PrinterType("yaml") // PrinterTypeHuman defines a human readable formatted formatter. PrinterTypeHuman = PrinterType("human") // PrinterTypeWide defines a human-readable formatted formatter without shrinking. PrinterTypeWide = PrinterType("wide") // PrinterTypeTemplate defines a go template to use to format output. PrinterTypeTemplate = PrinterType("template") // Option to enable pretty output on json printer. PrinterOptJSONPretty = "pretty" )
Variables ¶
var ( // UpdateGoldens will update all the golden files of a given test UpdateGoldens = flag.Bool("goldens", os.Getenv("CLI_UPDATE_GOLDENS") == "true", "Record goldens") // UpdateCassettes will update all cassettes of a given test UpdateCassettes = flag.Bool("cassettes", os.Getenv("CLI_UPDATE_CASSETTES") == "true", "Record Cassettes") // Debug set the log level to LogLevelDebug Debug = flag.Bool("debug", os.Getenv("SCW_DEBUG") == "true", "Enable Debug Mode") )
Test flags You can create a binary of each test using "go test -c -o myBinary"
var DefaultRetryInterval *time.Duration
DefaultRetryInterval is used across all wait functions in the CLI In particular it is very handy to define this RetryInterval at 0 second while running cassette in testing because they will be executed without waiting.
Functions ¶
func ApplyDefaultValues ¶
ApplyDefaultValues will hydrate args with default values.
func AutoCompleteArgValue ¶
func AutoCompleteArgValue(ctx context.Context, cmd *Command, argSpec *ArgSpec, argValuePrefix string) []string
AutoCompleteArgValue returns suggestions for a (argument name, argument value prefix) pair. Priority is given to the AutoCompleteFunc from the ArgSpec, if it is set. Otherwise, we use EnumValues from the ArgSpec.
func Bootstrap ¶
func Bootstrap(config *BootstrapConfig) (exitCode int, result interface{}, err error)
Bootstrap is the main entry point. It is directly called from main. BootstrapConfig.Args is usually os.Args BootstrapConfig.Commands is a list of command available in CLI.
func ExtractBinaryName ¶
func ExtractCacheDir ¶
func ExtractConfigPath ¶
func ExtractConfigPathFlag ¶
func ExtractProfileFlag ¶
func ExtractProfileName ¶
func ExtractUserHomeDir ¶
func GetDocGenContext ¶
GetDocGenContext reuturn a minimal context that can be used by scw-doc-gen
func GetProjectIDFromContext ¶
func GetRandomName ¶
GetRandomName returns a random name prefixed for the CLI.
func ReloadClient ¶
func RunShell ¶ added in v2.6.0
func RunShell(ctx context.Context, printer *Printer, meta *meta, rootCmd *cobra.Command, args []string)
RunShell will run an interactive shell that runs cobra commands
func Test ¶
func Test(config *TestConfig) func(t *testing.T)
Run a CLI integration test. See TestConfig for configuration option
Types ¶
type AfterFunc ¶
type AfterFunc func(ctx *AfterFuncCtx) error
func AfterFuncCombine ¶
AfterFuncCombine combines multiple after functions into one.
func ExecAfterCmd ¶
ExecAfterCmd executes the given before command.
type AfterFuncCtx ¶
type ArgSpec ¶
type ArgSpec struct {
// Name of the argument.
Name string
// Short description.
Short string
// Required defines whether the argument is required.
Required bool
// Default is the argument default value.
Default DefaultFunc
// EnumValues contains all possible values of an enum.
EnumValues []string
// AutoCompleteFunc is used to autocomplete possible values for a given argument.
AutoCompleteFunc AutoCompleteArgFunc
// ValidateFunc validates an argument.
ValidateFunc ArgSpecValidateFunc
// Positional defines whether the argument is a positional argument. NB: a positional argument is required.
Positional bool
// Only one argument of the same OneOfGroup could be specified
OneOfGroup string
// Deprecated is used to flag an argument as deprecated.
// Use the short field to indicate migration tips for users.
Deprecated bool
// CanLoadFile allow to use @ prefix to load a file as content
CanLoadFile bool
}
func OrganizationArgSpec ¶
func OrganizationArgSpec() *ArgSpec
func OrganizationIDArgSpec ¶
func OrganizationIDArgSpec() *ArgSpec
func ProjectArgSpec ¶
func ProjectArgSpec() *ArgSpec
func ProjectIDArgSpec ¶
func ProjectIDArgSpec() *ArgSpec
func RegionArgSpec ¶
func ZoneArgSpec ¶
func (*ArgSpec) ConflictWith ¶
func (*ArgSpec) IsPartOfMapOrSlice ¶
type ArgSpecValidateFunc ¶
ArgSpecValidateFunc validates one argument of a command.
func DefaultArgSpecValidateFunc ¶
func DefaultArgSpecValidateFunc() ArgSpecValidateFunc
DefaultArgSpecValidateFunc validates a value passed for an ArgSpec Uses ArgSpec.EnumValues
func ValidateOrganizationID ¶
func ValidateOrganizationID() ArgSpecValidateFunc
ValidateOrganizationID validates a non-required organization ID. By default, for most command, the organization ID is not required. In that case, we allow the empty-string value "".
func ValidateProjectID ¶
func ValidateProjectID() ArgSpecValidateFunc
ValidateProjectID validates a non-required project ID. By default, for most command, the project ID is not required. In that case, we allow the empty-string value "".
func ValidateSecretKey ¶
func ValidateSecretKey() ArgSpecValidateFunc
type ArgSpecs ¶
type ArgSpecs []*ArgSpec
func (*ArgSpecs) DeleteByName ¶
func (ArgSpecs) GetDeprecated ¶
GetDeprecated gets all fields filtered by the deprecation state.
func (ArgSpecs) GetPositionalArg ¶
type AutoCompleteArgFunc ¶
type AutoCompleteArgFunc func(ctx context.Context, prefix string) AutocompleteSuggestions
AutoCompleteArgFunc is the function called to complete arguments values. It is retrieved from core.ArgSpec.AutoCompleteFunc.
func AutocompleteProfileName ¶
func AutocompleteProfileName() AutoCompleteArgFunc
type AutoCompleteNode ¶
type AutoCompleteNode struct {
Children map[string]*AutoCompleteNode
Command *Command
ArgSpec *ArgSpec
Type AutoCompleteNodeType
// Name of the current node. Useful for debugging.
Name string
}
AutoCompleteNode is a node in the AutoComplete Tree. An AutoCompleteNode can either represent a command, a subcommand, or a command argument.
func BuildAutoCompleteTree ¶
func BuildAutoCompleteTree(commands *Commands) *AutoCompleteNode
BuildAutoCompleteTree builds the autocomplete tree from the commands, subcommands and arguments
func NewAutoCompleteArgNode ¶
func NewAutoCompleteArgNode(cmd *Command, argSpec *ArgSpec) *AutoCompleteNode
NewAutoCompleteArgNode creates a new node corresponding to a command argument. These nodes are leaf nodes.
func NewAutoCompleteCommandNode ¶
func NewAutoCompleteCommandNode() *AutoCompleteNode
NewAutoCompleteCommandNode creates a new node corresponding to a command or subcommand. These nodes are not necessarily leaf nodes.
func NewAutoCompleteFlagNode ¶
func NewAutoCompleteFlagNode(parent *AutoCompleteNode, flagSpec *FlagSpec) *AutoCompleteNode
NewAutoCompleteFlagNode returns a node representing a Flag. It creates the children node with possible values if they exist. It sets parent.children as children of the lowest nodes: the lowest node is the flag if it has no possible value ; or the lowest nodes are the possible values if the exist.
func (*AutoCompleteNode) GetChildMatch ¶
func (node *AutoCompleteNode) GetChildMatch(name string) (*AutoCompleteNode, bool)
GetChildMatch returns a child for a node if the child exists for this node. 3 types of children are supported : - command: command - singular argument name: argument= - plural argument name + alphanumeric: arguments.key1=
func (*AutoCompleteNode) GetChildOrCreate ¶
func (node *AutoCompleteNode) GetChildOrCreate(name string) *AutoCompleteNode
GetChildOrCreate search a child node by name, and either returns it if found or create a new child with the given name, and returns it.
type AutoCompleteNodeType ¶
type AutoCompleteNodeType uint
const ( AutoCompleteNodeTypeCommand AutoCompleteNodeType = iota AutoCompleteNodeTypeArgument AutoCompleteNodeTypeFlag AutoCompleteNodeTypeFlagValueConst AutoCompleteNodeTypeFlagValueVariable )
type AutocompleteResponse ¶
type AutocompleteResponse struct {
Suggestions AutocompleteSuggestions
}
AutocompleteResponse contains the autocomplete suggestions
func AutoComplete ¶
func AutoComplete(ctx context.Context, leftWords []string, wordToComplete string, rightWords []string) *AutocompleteResponse
AutoComplete process a command line and returns autocompletion suggestions.
command <flag name>=<flag value beginning><tab> gives no suggestion for now eg: scw test flower create name=p -o=jso
type AutocompleteSuggestions ¶
type AutocompleteSuggestions []string
AutocompleteSuggestions is a list of words to be set to the shell as autocomplete suggestions.
type BeforeFunc ¶
type BeforeFunc func(ctx *BeforeFuncCtx) error
func BeforeFuncCombine ¶
func BeforeFuncCombine(beforeFuncs ...BeforeFunc) BeforeFunc
BeforeFuncCombine combines multiple before functions into one.
func BeforeFuncOsExec ¶
func BeforeFuncOsExec(cmd string, args ...string) BeforeFunc
func BeforeFuncStoreInMeta ¶
func BeforeFuncStoreInMeta(key string, value interface{}) BeforeFunc
func BeforeFuncWhenUpdatingCassette ¶
func BeforeFuncWhenUpdatingCassette(beforeFunc BeforeFunc) BeforeFunc
func ExecBeforeCmd ¶
func ExecBeforeCmd(cmd string) BeforeFunc
ExecBeforeCmd executes the given before command.
func ExecStoreBeforeCmd ¶
func ExecStoreBeforeCmd(metaKey, cmd string) BeforeFunc
ExecStoreBeforeCmd executes the given before command and register the result in the context Meta at metaKey.
type BeforeFuncCtx ¶
type BootstrapConfig ¶
type BootstrapConfig struct {
// Args to use for the command. Usually os.Args
Args []string
// A list of all available commands
Commands *Commands
// BuildInfo contains information about cli build
BuildInfo *BuildInfo
// Stdout stream to use. Usually os.Stdout
Stdout io.Writer
// Stderr stream to use. Usually os.Stderr
Stderr io.Writer
// Stdin stream to use. Usually os.Stdin
Stdin io.Reader
// If provided this client will be passed to all commands.
// If not a client will be automatically created by the CLI using Config, Env and flags see createClient().
Client *scw.Client
// DisableTelemetry, if set to true this will disable telemetry report no matter what the config send_telemetry is set to.
// This is useful when running test to avoid sending meaningless telemetries.
DisableTelemetry bool
// OverrideEnv overrides environment variables returned by core.ExtractEnv function.
// This is useful for tests as it allows overriding env without relying on global state.
OverrideEnv map[string]string
// OverrideExec allow to override exec.Cmd.Run method. In order for this to work
// your code must call le core.ExecCmd function to execute a given command.
// If this function is not defined the exec.Cmd.Run function will be called directly.
// This function is intended to be use for tests purposes.
OverrideExec OverrideExecFunc
// BaseContest is the base context that will be used across all function call from top to bottom.
Ctx context.Context
// Optional we use it if defined
Logger *Logger
// Default HTTPClient to use. If not provided it will use a basic http client with a simple retry policy
// This client will be used to create SDK client, account call, version checking and telemetry
HTTPClient *http.Client
}
type BuildInfo ¶
type BuildInfo struct {
Version *version.Version `json:"-"`
BuildDate string `json:"build_date"`
GoVersion string `json:"go_version"`
GitBranch string `json:"git_branch"`
GitCommit string `json:"git_commit"`
GoArch string `json:"go_arch"`
GoOS string `json:"go_os"`
}
func ExtractBuildInfo ¶
func (*BuildInfo) GetUserAgent ¶
func (*BuildInfo) IsRelease ¶
IsRelease returns true when the version of the CLI is an official release: - version must be non-empty (exclude tests) - version must not contain metadata (e.g. '+dev')
func (*BuildInfo) MarshalJSON ¶
type CheckFuncCtx ¶
type CheckFuncCtx struct {
// Exit code return by the CLI
ExitCode int
// Content print on stdout
Stdout []byte
// Content print on stderr
Stderr []byte
// Error returned by the command
Err error
// Command result
Result interface{}
// Meta bag
Meta testMetadata
// Scaleway client
Client *scw.Client
// OverrideEnv passed in the TestConfig
OverrideEnv map[string]string
Logger *Logger
// The content logged by the command
LogBuffer string
}
CheckFuncCtx contain the result of a command execution
type CliError ¶
type CliError struct {
// The original error that triggers this CLI error.
// The Err.String() will be print in red to the user.
Err error
// Message allow to override the red message shown to the use.
// By default we will use Err.String() but in same case you may want to keep Err
// to avoid loosing detail in json output.
Message string
Details string
Hint string
// Code allows to return a sepcific error code from the main binary.
Code int
// Empty tells the marshaler to not print any message for the error
Empty bool
}
CliError is an all-in-one error structure that can be used in commands to return useful errors to the user. CliError implements JSON and human marshaler for a smooth experience.
func ArgumentConflictError ¶
func InvalidAccessKeyError ¶
func InvalidProjectIDError ¶
func InvalidSecretKeyError ¶
func WindowIsNotSupportedError ¶
func WindowIsNotSupportedError() *CliError
func (*CliError) MarshalHuman ¶
func (*CliError) MarshalJSON ¶
type Command ¶
type Command struct {
// Namespace is the top level entry point of a command. (e.g scw instance)
Namespace string
// Resource is the 2nd command level. Resources are nested in a namespace. (e.g scw instance server)
Resource string
// Verb is the 3rd command level. Verbs are nested in a resource. (e.g scw instance server list)
Verb string
// Short documentation.
Short string
// Long documentation.
Long string
// AllowAnonymousClient defines whether the SDK client can run the command without be authenticated.
AllowAnonymousClient bool
// DisableTelemetry disable telemetry for the command.
DisableTelemetry bool
// Hidden hides the command form usage and auto-complete.
Hidden bool
// ArgsType defines the type of argument for this command.
ArgsType reflect.Type
// ArgSpecs defines specifications for arguments.
ArgSpecs ArgSpecs
// View defines the View for this command.
// It is used to create the different options for the different Marshalers.
View *View
// Examples defines Examples for this command.
Examples []*Example
// SeeAlsos presents commands related to this command.
SeeAlsos []*SeeAlso
// PreValidateFunc allows to manipulate args before validation
PreValidateFunc CommandPreValidateFunc
// ValidateFunc validates a command.
// If nil, core.DefaultCommandValidateFunc is used by default.
ValidateFunc CommandValidateFunc
// Interceptor are middleware func that can intercept context and args before they are sent to Run
// You can combine multiple CommandInterceptor using AddInterceptors method.
Interceptor CommandInterceptor
// Run will be called to execute a command. It will receive a context and parsed argument.
// Non-nil values returned by this method will be printed out.
Run CommandRunner
// WaitFunc will be called if non-nil when the -w (--wait) flag is passed.
WaitFunc WaitFunc
}
Command represent a CLI command. From this higher level type we create Cobra command objects.
func (*Command) AddInterceptors ¶
func (c *Command) AddInterceptors(interceptors ...CommandInterceptor)
AddInterceptors add one or multiple interceptors to a command. These new interceptors will be added after the already present interceptors (if any).
func (*Command) GetCommandLine ¶
type CommandInterceptor ¶
type CommandInterceptor func(ctx context.Context, argsI interface{}, runner CommandRunner) (interface{}, error)
CommandInterceptor allow to intercept and manipulate a runner arguments and return value. It can for example be used to change arguments type or catch runner errors.
type CommandPreValidateFunc ¶
CommandPreValidateFunc allows to manipulate args before validation.
type CommandRunner ¶
CommandRunner returns the command response or an error.
type CommandValidateFunc ¶
type CommandValidateFunc func(ctx context.Context, cmd *Command, cmdArgs interface{}, rawArgs args.RawArgs) error
CommandValidateFunc validates en entire command. Used in core.cobraRun().
func DefaultCommandValidateFunc ¶
func DefaultCommandValidateFunc() CommandValidateFunc
DefaultCommandValidateFunc is the default validation function for commands.
type Commands ¶
type Commands struct {
// contains filtered or unexported fields
}
Commands represent a list of CLI commands, with a index to allow searching.
func ExtractCommands ¶
func NewCommands ¶
func (*Commands) GetSortedCommand ¶
GetSortedCommand returns a slice of commands sorted alphabetically
func (*Commands) HasSubCommands ¶
type Completer ¶ added in v2.6.0
type Completer struct {
// contains filtered or unexported fields
}
func NewShellCompleter ¶ added in v2.6.0
type DefaultFunc ¶
func DefaultValueSetter ¶
func DefaultValueSetter(defaultValue string) DefaultFunc
func RandomValueGenerator ¶
func RandomValueGenerator(prefix string) DefaultFunc
type Example ¶
type Example struct {
// Short is the title given to the example.
Short string
// ArgsJSON is a JSON encoded representation of the request used in the example. Only one of ArgsJSON or Raw should be provided.
ArgsJSON string
// Raw is a raw example. Only one of ArgsJSON or Raw should be provided.
Raw string
}
Example represents an example for the usage of a CLI command.
type MultiResults ¶
type MultiResults []interface{}
func (MultiResults) MarshalHuman ¶
func (mr MultiResults) MarshalHuman() (string, error)
type OverrideExecTestFunc ¶
type OverrideExecTestFunc func(ctx *ExecFuncCtx, cmd *exec.Cmd) (exitCode int, err error)
func OverrideExecSimple ¶
func OverrideExecSimple(cmdStr string, exitCode int) OverrideExecTestFunc
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
func NewPrinter ¶
func NewPrinter(config *PrinterConfig) (*Printer, error)
NewPrinter returns an initialized formatter corresponding to a given FormatterType.
type PrinterConfig ¶
type PrinterType ¶
type PrinterType string
Type defines an formatter format.
func (PrinterType) String ¶
func (p PrinterType) String() string
type RawResult ¶
type RawResult []byte
This type can be return by a command that need to output specific content on stdout directly. When a command return this type, default printer will not be used and bytes will be directly print on stdout.
type ShellSuggestion ¶ added in v2.6.0
type SuccessResult ¶
func (*SuccessResult) MarshalHuman ¶
func (s *SuccessResult) MarshalHuman() (string, error)
func (*SuccessResult) MarshalJSON ¶
func (s *SuccessResult) MarshalJSON() ([]byte, error)
type TestCheck ¶
type TestCheck func(t *testing.T, ctx *CheckFuncCtx)
TestCheck is a function that perform assertion on a CheckFuncCtx
func TestCheckCombine ¶
TestCheckCombine combines multiple check functions into one.
func TestCheckExitCode ¶
TestCheckExitCode assert exitCode
func TestCheckGolden ¶
func TestCheckGolden() TestCheck
TestCheckGolden assert stderr and stdout using golden
func TestCheckStdout ¶
TestCheckStdout asserts stdout using string
type TestConfig ¶
type TestConfig struct {
// Array of command to load (see main.go)
Commands *Commands
// If set to true the client will be initialize to use a e2e token.
UseE2EClient bool
// DefaultRegion to use with scw client (default: scw.RegionFrPar)
DefaultRegion scw.Region
// DefaultZone to use with scw client (default: scw.ZoneFrPar1)
DefaultZone scw.Zone
// BeforeFunc is a hook that will be called before test is run. You can use this function to bootstrap resources.
BeforeFunc BeforeFunc
// The command line you want to test
// The arguments in this command MUST have only one space between each others to be split successfully
// Conflict with Args
Cmd string
// Args represents a program arguments and should be used, when you cannot Cmd because your arguments include space characters
// Conflict with Cmd
Args []string
// A list of check function that will be run on result.
Check TestCheck
// AfterFunc is a hook that will be called after test is run. You can use this function to teardown resources.
AfterFunc AfterFunc
// Run tests in parallel.
DisableParallel bool
// Fake build info for this test.
BuildInfo *BuildInfo
// If set, it will create a temporary home directory during the tests.
// Get this folder with ExtractUserHomeDir()
// This will also use this temporary directory as a cache directory.
// Get this folder with ExtractCacheDir()
TmpHomeDir bool
// OverrideEnv contains environment variables that will be overridden during the test.
OverrideEnv map[string]string
// see BootstrapConfig.OverrideExec
OverrideExec OverrideExecTestFunc
// Custom client to use for test, if none are provided will create one automatically
Client *scw.Client
// Context that will be forwarded to Bootstrap
Ctx context.Context
// If this is specified this value will be passed to interactive.InjectMockResponseToContext ans will allow
// to mock response a user would have enter in a prompt.
// Warning: All prompts MUST be mocked or test will hang.
PromptResponseMocks []string
// Allow to mock stdin
Stdin io.Reader
}
TestConfig contain configuration that can be used with the Test function
type View ¶
type View struct {
Title string
Fields []*ViewField
Sections []*ViewSection
}
View hydrates human.MarshalOpt
type ViewSection ¶
Source Files
¶
- arg_file_content.go
- arg_specs.go
- autocomplete.go
- autocomplete_utils.go
- bootstrap.go
- build_info.go
- client.go
- cobra_builder.go
- cobra_usage_builder.go
- cobra_utils.go
- command.go
- command_interceptor.go
- context.go
- default.go
- error.go
- errors.go
- example.go
- exec.go
- http_retry.go
- logger.go
- printer.go
- reflect.go
- result.go
- see_also.go
- shell.go
- testing.go
- validate.go
- view.go