Documentation ¶
Index ¶
- func CheckForUnknown(fldPath *field.Path, orig, accepted interface{}) field.ErrorList
- func CheckForUnknownElements(fldPath *field.Path, orig, accepted []interface{}) field.ErrorList
- func CheckForUnknownFields(fldPath *field.Path, orig, accepted map[string]interface{}) field.ErrorList
- func HandleArgs(opts *output.Options, handler TypeHandler, args ...string) error
- func HandleOutput(output output.Output, handler TypeHandler, specs ...ElemSpec) error
- func HandleOutputs(opts *output.Options, handler TypeHandler, args ...ElemSpec) error
- func HideCommand(cmd *cobra.Command) *cobra.Command
- func IsExecutable(path string, fss ...vfs.FileSystem) bool
- func MassageCommand(cmd *cobra.Command, names ...string) *cobra.Command
- func Names(def []string, names ...string) []string
- func OverviewCommand(cmd *cobra.Command) *cobra.Command
- func Plural[N constraints.Integer](s string, amount ...N) string
- func SetupCommand(ocmcmd OCMCommand, names ...string) *cobra.Command
- func SplitPathList(pathList string) []string
- type BaseCommand
- type CommandTweaker
- type ElemSpec
- type Example
- type Long
- type OCMCommand
- type Short
- type StringSpec
- type TypeHandler
- type Updater
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckForUnknown ¶
func CheckForUnknownElements ¶
func CheckForUnknownFields ¶
func HandleArgs ¶
func HandleArgs(opts *output.Options, handler TypeHandler, args ...string) error
func HandleOutput ¶
func HandleOutput(output output.Output, handler TypeHandler, specs ...ElemSpec) error
func HandleOutputs ¶
func HandleOutputs(opts *output.Options, handler TypeHandler, args ...ElemSpec) error
func IsExecutable ¶
func IsExecutable(path string, fss ...vfs.FileSystem) bool
IsExecutable returns true if a given file is executable.
func SetupCommand ¶
func SetupCommand(ocmcmd OCMCommand, names ...string) *cobra.Command
SetupCommand uses the OCMCommand to create and tweak a cobra command to incorporate the additional reusable option specs and their usage documentation. Before the command executions the various Complete method flavors are executed on the additional options ond the OCMCommand. It also prepares the help system to reflect dynamic settings provided by root command options by using a generated update function based on optional methods of the OCM command.
func SplitPathList ¶
SplitPathList splits a path list. This is based on genSplit from strings/strings.go
Types ¶
type BaseCommand ¶
BaseCommand provides the basic functionality of an OCM command to carry a context and a set of reusable option specs.
func NewBaseCommand ¶
func NewBaseCommand(ctx clictx.Context, opts ...options.Options) BaseCommand
func (BaseCommand) Complete ¶
func (BaseCommand) Complete(args []string) error
type CommandTweaker ¶
type Example ¶
type Example interface {
Example() string
}
Example is used to provide the example description by a method of the command.
type Long ¶
type Long interface {
Long() string
}
Long is used to provide the long description by a method of the command.
type OCMCommand ¶
type OCMCommand interface { clictx.Context // ForName create a new cobra command for the given command name. // The Use attribute should omit the command name and just provide // a ost argument synopsis. // the complete attribute set is tweaked with the SetupCommand function // which calls this method. // Basically this should be an inherited function by the base implementation // but GO does not support virtual methods, therefore it is a global // function instead of a method. ForName(name string) *cobra.Command AddFlags(fs *pflag.FlagSet) Complete(args []string) error Run() error }
OCMCommand is a command pattern, that can be instantiated for a dediated sub command name to create a cobra command.
type Short ¶
type Short interface {
Short() string
}
Short is used to provide the short description by a method of the command.
type StringSpec ¶
type StringSpec string
func (StringSpec) String ¶
func (s StringSpec) String() string
type TypeHandler ¶
type TypeHandler interface { // All returns all elements according to its context All() ([]output.Object, error) // Get returns the elements for a dedicated specification // according to the handlers context. Get(name ElemSpec) ([]output.Object, error) Close() error }
TypeHandler provides base input to an output processing chain using HandleArsg or HandleOutput(s). It provides the exploding of intials specifications to effective objects passed to the output processing chain.