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 FormatList(def string, elems ...string) string
- func FormatListElements(def string, elems ListElements) string
- func FormatMapElements[E any](def string, m map[string]E, desc func(E) string) string
- 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 MassageCommand(cmd *cobra.Command, names ...string) *cobra.Command
- func Names(def []string, names ...string) []string
- func Plural[N constraints.Integer](s string, amount ...N) string
- func SetupCommand(ocmcmd OCMCommand, names ...string) *cobra.Command
- type BaseCommand
- type CommandTweaker
- type ElemSpec
- type Example
- type IdentityMatcherList
- type ListElements
- type Long
- type OCMCommand
- type Short
- type StringElementList
- type StringSpec
- type TypeHandler
- type Updater
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckForUnknown ¶
func CheckForUnknownElements ¶
func CheckForUnknownFields ¶
func FormatList ¶
func FormatListElements ¶
func FormatListElements(def string, elems ListElements) string
func FormatMapElements ¶
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 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.
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 IdentityMatcherList ¶
type IdentityMatcherList []credentials.IdentityMatcherInfo
func (IdentityMatcherList) Description ¶
func (l IdentityMatcherList) Description(i int) string
func (IdentityMatcherList) Key ¶
func (l IdentityMatcherList) Key(i int) string
func (IdentityMatcherList) Size ¶
func (l IdentityMatcherList) Size() int
type ListElements ¶
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 StringElementList ¶
type StringElementList []string
func (StringElementList) Description ¶
func (l StringElementList) Description(i int) string
func (StringElementList) Key ¶
func (l StringElementList) Key(i int) string
func (StringElementList) Size ¶
func (l StringElementList) Size() int
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.