cli

package
v0.0.0-...-8035709 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: Apache-2.0 Imports: 14 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// Arg : To set a ForjParam as Argument.
	Arg = "arg"
	// Flag : To set a ForjParam as Flag.
	Flag = "flag"
)

ForjParams type

View Source
const (
	// String - Define the Param data type to string.
	String = "string"
	// Bool - Define the Param data type to bool.
	Bool = "bool"
	// List - Define a ForjObjectList data type.
	List = "list"
)

List of ForjParams internal types

Variables

This section is empty.

Functions

func Split

func Split(expr, s, sep string) []string

Types

type ForjAction

type ForjAction struct {
	// contains filtered or unexported fields
}

ForjActionRef To define an action reference

func (*ForjAction) GetBoolAddr

func (a *ForjAction) GetBoolAddr(param_name string) *bool

func (*ForjAction) GetStringAddr

func (a *ForjAction) GetStringAddr(param_name string) *string

func (*ForjAction) String

func (a *ForjAction) String() string

type ForjArg

type ForjArg struct {
	// contains filtered or unexported fields
}

ForjArg defines the flag structure for each object actions

func NewForjArg

func NewForjArg(arg clier.ArgClauser) (f *ForjArg)

NewForjArg creates ForjArg object from a argClauser

func (*ForjArg) Copier

func (a *ForjArg) Copier() (p ForjParamCopier)

func (*ForjArg) CopyToArg

func (a *ForjArg) CopyToArg(cmd clier.CmdClauser) *ForjArg

func (*ForjArg) CopyToFlag

func (a *ForjArg) CopyToFlag(cmd clier.CmdClauser) *ForjFlag

func (*ForjArg) Default

func (a *ForjArg) Default(value string) ForjParam

func (*ForjArg) GetArg

func (a *ForjArg) GetArg() *ForjArg

func (*ForjArg) GetBoolAddr

func (a *ForjArg) GetBoolAddr() *bool

GetBoolAddr return the address to the bool value. Used in conjunction with Selected Actions AddFlag/AddArg.

func (*ForjArg) GetBoolValue

func (a *ForjArg) GetBoolValue() bool

func (*ForjArg) GetContextValue

func (a *ForjArg) GetContextValue(context clier.ParseContexter) (interface{}, bool)

func (*ForjArg) GetFlag

func (*ForjArg) GetFlag() *ForjFlag

func (*ForjArg) GetListValues

func (a *ForjArg) GetListValues() []ForjData

func (*ForjArg) GetStringAddr

func (a *ForjArg) GetStringAddr() *string

func (*ForjArg) GetStringValue

func (a *ForjArg) GetStringValue() string

func (*ForjArg) GetValue

func (f *ForjArg) GetValue() interface{}

func (*ForjArg) IsFound

func (a *ForjArg) IsFound() bool

func (*ForjArg) IsFromObject

func (f *ForjArg) IsFromObject(obj *ForjObject) bool

func (*ForjArg) IsList

func (f *ForjArg) IsList() bool

func (*ForjArg) Name

func (a *ForjArg) Name() string

func (*ForjArg) String

func (a *ForjArg) String() string

func (*ForjArg) Type

func (f *ForjArg) Type() string

func (*ForjArg) UpdateObject

func (a *ForjArg) UpdateObject() error

type ForjArgList

type ForjArgList struct {
	// contains filtered or unexported fields
}

ForjArgList defines the flag list structure for each object actions

func (*ForjArgList) Copier

func (a *ForjArgList) Copier() (p ForjParamCopier)

func (*ForjArgList) CopyToArg

func (a *ForjArgList) CopyToArg(cmd clier.CmdClauser) *ForjArg

func (*ForjArgList) CopyToFlag

func (a *ForjArgList) CopyToFlag(cmd clier.CmdClauser) *ForjFlag

func (*ForjArgList) Default

func (f *ForjArgList) Default(value string) (ret ForjParam)

func (*ForjArgList) GetArgClauser

func (a *ForjArgList) GetArgClauser() clier.ArgClauser

func (*ForjArgList) GetBoolAddr

func (f *ForjArgList) GetBoolAddr() *bool

func (*ForjArgList) GetBoolValue

func (f *ForjArgList) GetBoolValue() bool

func (*ForjArgList) GetContextValue

func (a *ForjArgList) GetContextValue(context clier.ParseContexter) (interface{}, bool)

func (*ForjArgList) GetListValues

func (f *ForjArgList) GetListValues() []ForjListData

func (*ForjArgList) GetStringAddr

func (f *ForjArgList) GetStringAddr() *string

func (*ForjArgList) GetStringValue

func (f *ForjArgList) GetStringValue() string

func (*ForjArgList) GetValue

func (f *ForjArgList) GetValue() interface{}

func (*ForjArgList) IsFound

func (f *ForjArgList) IsFound() bool

func (*ForjArgList) IsFromObject

func (a *ForjArgList) IsFromObject(obj *ForjObject) bool

func (*ForjArgList) IsList

func (f *ForjArgList) IsList() bool

func (*ForjArgList) Name

func (a *ForjArgList) Name() string

func (*ForjArgList) String

func (a *ForjArgList) String() (ret string)

func (*ForjArgList) Type

func (f *ForjArgList) Type() string

type ForjCli

type ForjCli struct {
	App clier.Applicationer // *kingpin.Application       // Kingpin Application object
	// contains filtered or unexported fields
}

ForjCli is the Core cli for forjj command.

func NewForjCli

func NewForjCli(app clier.Applicationer) (c *ForjCli)

NewForjCli : Initialize a new ForjCli object

panic if app is nil.

func (*ForjCli) AddActionFlagFromObjectAction

func (c *ForjCli) AddActionFlagFromObjectAction(obj_name, obj_action, param_name string) *ForjCli

AddActionFlagFromObjectAction create one flag defined on an object action to selected action.

func (*ForjCli) AddActionFlagFromObjectField

func (c *ForjCli) AddActionFlagFromObjectField(param_name string, options *ForjOpts) *ForjCli

AddActionFlagFromObjectField declare one flag from an object field to selected action. One or more instance flags can be created as soon as object instances are loaded from addInstanceFlags() function.

func (*ForjCli) AddActionFlagFromObjectListAction

func (c *ForjCli) AddActionFlagFromObjectListAction(obj_name, obj_list, obj_action string) *ForjCli

AddActionFlagFromObjectListAction add one ObjectList action to the selected list of actions (OnActions).

Ex:<app> update --tests "flag_key" The collection of object flag can be added at parse time. ex: <app> update --tests "key1,key2" --key1-flag <data> --key2-flag <data>

func (*ForjCli) AddActionFlagsFromObjectAction

func (c *ForjCli) AddActionFlagsFromObjectAction(obj_name, obj_action string) *ForjCli

AddActionFlagsFromObjectAction create all flags defined on an object action to selected action.

func (*ForjCli) AddActionFlagsFromObjectListActions

func (c *ForjCli) AddActionFlagsFromObjectListActions(obj_name, obj_list string, obj_actions ...string) *ForjCli

AddActionFlagsFromObjectListActions add one ObjectList action to the selected list of actions (OnActions). Ex: <app> update --add-tests "flag_key" --remove-tests "test,test2"

func (*ForjCli) AddAppFlag

func (c *ForjCli) AddAppFlag(paramIntType, name, help string, options *ForjOpts)

AddAppFlag create a flag object at the application layer.

func (*ForjCli) AddArg

func (c *ForjCli) AddArg(value_type, name, help string, options *ForjOpts) *ForjCli

AddArg Add an arg on selected actions You could get values With 2 different possible functions (where <Type> can be cli.String or cli.Bool) - Get<Type>Value() to get the typed value - Get<Type>Addr() to get the pointer to the value

func (*ForjCli) AddFieldListCapture

func (c *ForjCli) AddFieldListCapture(key, capture string) error

AddFieldListCapture Add a Field list capture

func (*ForjCli) AddFlag

func (c *ForjCli) AddFlag(value_type, name, help string, options *ForjOpts) *ForjCli

AddFlag Add an flag on selected actions You could get values With 2 different possible functions (where <Type> can be cli.String or cli.Bool) - Get<Type>Value() to get the typed value - Get<Type>Addr() to get the pointer to the value

func (*ForjCli) ContextHook

func (c *ForjCli) ContextHook(context interface{}) (error, bool)

func (*ForjCli) Error

func (c *ForjCli) Error() error

func (*ForjCli) GetAction

func (c *ForjCli) GetAction(name string) *ForjAction

func (*ForjCli) GetActionBoolValue

func (c *ForjCli) GetActionBoolValue(action_name, paramValue string) (bool, error)

GetActionStringValue return a string of the parameter (flag/arg) attached to an action. An empty string is returned if:

- the parameter is not found

- a different type

- parameter value is ""

To check if the parameter exist, use IsAppValueFound.

Note that this function works during the parse context.

func (*ForjCli) GetActionStringValue

func (c *ForjCli) GetActionStringValue(action_name, paramValue string) (string, error)

GetActionStringValue return a string of the parameter (flag/arg) attached to an action. An empty string is returned if:

- the parameter is not found

- a different type

- parameter value is ""

To check if the parameter exist, use IsAppValueFound.

Note that this function works during the parse context.

func (*ForjCli) GetAllActions

func (c *ForjCli) GetAllActions() map[string]*ForjAction

GetAllActions return the list of actions and definitions defined by the application.

func (*ForjCli) GetAppBoolValue

func (c *ForjCli) GetAppBoolValue(paramValue string) (bool, error)

GetAppBoolValue return a bool value of the parameter found at App layer. return false if

- the parameter is not found

- a different type

- parameter value is false

To check if the parameter exist, use IsAppValueFound.

Note that this function works during the parse context.

It returns an error if:

- the parameter has not been defined in the application layer. Missing AddAppFlag.

- If the context is nil. Means no parse has been executed.

func (*ForjCli) GetAppFlag

func (c *ForjCli) GetAppFlag(paramValue string) *ForjFlag

GetAppFlag return the Application layer flag named paramValue.

func (*ForjCli) GetAppStringValue

func (c *ForjCli) GetAppStringValue(paramValue string) (string, error)

GetAppStringValue return a string of the parameter at App layer. An empty string is returned if:

- the parameter is not found

- a different type

- parameter value is ""

To check if the parameter exist, use IsAppValueFound.

Note that this function works during the parse context.

It returns an error if:

- the parameter has not been defined in the application layer. Missing AddAppFlag.

- If the context is nil. Means no parse has been executed.

func (*ForjCli) GetBoolValue

func (c *ForjCli) GetBoolValue(object, key, param_name string) (bool, bool, error)

GetBoolValue : Get a Boolean of the parameter from cli.

Get data from object defined. if object == "application", it will get data from the Application layer

func (*ForjCli) GetCurrentCommand

func (c *ForjCli) GetCurrentCommand() []clier.CmdClauser

func (*ForjCli) GetObject

func (c *ForjCli) GetObject(obj_name string) *ForjObject

func (*ForjCli) GetObjectValues

func (c *ForjCli) GetObjectValues(obj_name string) map[string]*ForjData

func (*ForjCli) GetParseContext

func (c *ForjCli) GetParseContext() clier.ParseContexter

GetParseContext return the internal parseContext object

func (*ForjCli) GetStringValue

func (c *ForjCli) GetStringValue(object, key, param_name string) (string, bool, bool, error)

GetStringValue : Get a String of the parameter from cli.

Get data from object defined. if object == "application", it will get data from the Application layer

returns: - value - found - default : If value is a pointer to a string, default is set to true. - error

func (*ForjCli) GetStringValueAddr

func (c *ForjCli) GetStringValueAddr(name string) *string

GetStringValueAddr : Provide the Address to the flag/argument value if is a *string. It returns nil if the flag/arg was not found or is not a string.

func (*ForjCli) IsAppValueFound

func (c *ForjCli) IsAppValueFound(paramValue string) bool

IsAppValueFound return true if the parameter value is found on App Layer

func (*ForjCli) IsObjectList

func (c *ForjCli) IsObjectList(object, key, obj_name string) bool

IsObjectList returns - true if the context is a list and is that object. - true if the action has a ObjectList

func (*ForjCli) IsParamFound

func (c *ForjCli) IsParamFound(param_name string) (found bool)

IsParamFound. Search in defined parameter if it exists

func (*ForjCli) IsParsePhase

func (c *ForjCli) IsParsePhase() bool

func (*ForjCli) LoadCli

func (c *ForjCli) LoadCli() error

LoadCli Same as LoadContext. But in final stage

Load all cli data to internal object representative

func (*ForjCli) LoadPluginData

func (c *ForjCli) LoadPluginData(data *goforjj.YamlPluginComm) error

LoadPluginData: Load Plugin Definition in cli.

func (*ForjCli) LoadValuesFrom

func (c *ForjCli) LoadValuesFrom(context clier.ParseContexter)

LoadValuesFrom load most of flags/arguments found in the cli context in values, like kingpin.execute do.

func (*ForjCli) NewActions

func (c *ForjCli) NewActions(name, act_help, compose_help string, for_forjj bool) (r *ForjAction)

NewActions create the list of referenced valid actions supported. kingpin layer created. It add them to the kingpin application layer.

name : Name of the action to add help : Generic help to add to the action. for_forjj: True if the action is protected against plugins features.

func (*ForjCli) NewObject

func (c *ForjCli) NewObject(name, desc string, role string) *ForjObject

NewObjectActions add a new object and the list of actions. It creates the ForjAction object for each action/object couple, to attach the object to kingpin object layer.

func (*ForjCli) OnActions

func (c *ForjCli) OnActions(actions ...string) *ForjCli

OnActions Do a selection of action to apply more functionality

func (*ForjCli) Parse

func (c *ForjCli) Parse(args []string, context interface{}) (cmd string, err error)

Parse do the parse of the command line

func (*ForjCli) ParseAfterHook

func (c *ForjCli) ParseAfterHook(context_hook func(*ForjCli, interface{}) (error, bool)) *ForjCli

ParseAfterHook defines a hook that will be executed after object list and object hooks

func (*ForjCli) ParseBeforeHook

func (c *ForjCli) ParseBeforeHook(context_hook func(*ForjCli, interface{}) (error, bool)) *ForjCli

ParseBeforeHook defines a hook that will be executed before object list and object hooks

func (*ForjCli) SetValue

func (c *ForjCli) SetValue(object, instance, atype, attr string, value interface{}) (err error)

func (*ForjCli) String

func (c *ForjCli) String() (ret string)

func (*ForjCli) WithObjectInstance

func (c *ForjCli) WithObjectInstance(object_name, instance_name string) *ForjCli

type ForjCliContext

type ForjCliContext struct {
	// contains filtered or unexported fields
}

type ForjContextTime

type ForjContextTime struct {
	// contains filtered or unexported fields
}

ForjContextTime. Structure used at context time to add more flags from Objectlist instances or Add Object fields Flags from instances.

type ForjData

type ForjData struct {
	// contains filtered or unexported fields
}

func (*ForjData) Attrs

func (r *ForjData) Attrs() map[string]interface{}

func (*ForjData) Get

func (d *ForjData) Get(param string) (ret interface{}, found bool, err error)

func (*ForjData) GetString

func (d *ForjData) GetString(param string) (ret string)

func (*ForjData) Keys

func (r *ForjData) Keys() (keys []string)

type ForjField

type ForjField struct {
	// contains filtered or unexported fields
}

func NewField

func NewField(o *ForjObject, pIntType, name, help, re string, opts *ForjOpts) *ForjField

func (*ForjField) String

func (f *ForjField) String() string

type ForjFlag

type ForjFlag struct {
	// contains filtered or unexported fields
}

ForjFlag defines the flag structure for each object actions

func NewForjFlag

func NewForjFlag(flag clier.FlagClauser) (f *ForjFlag)

NewForjFlag creates ForjFlag object from a flagClauser

func (*ForjFlag) Copier

func (a *ForjFlag) Copier() (p ForjParamCopier)

func (*ForjFlag) CopyToArg

func (f *ForjFlag) CopyToArg(cmd clier.CmdClauser) *ForjArg

func (*ForjFlag) CopyToFlag

func (f *ForjFlag) CopyToFlag(cmd clier.CmdClauser) *ForjFlag

func (*ForjFlag) Default

func (f *ForjFlag) Default(value string) ForjParam

func (*ForjFlag) GetArg

func (*ForjFlag) GetArg() *ForjArg

func (*ForjFlag) GetBoolAddr

func (f *ForjFlag) GetBoolAddr() *bool

func (*ForjFlag) GetBoolValue

func (f *ForjFlag) GetBoolValue() bool

func (*ForjFlag) GetContextValue

func (f *ForjFlag) GetContextValue(context clier.ParseContexter) (interface{}, bool)

func (*ForjFlag) GetFlag

func (f *ForjFlag) GetFlag() *ForjFlag

func (*ForjFlag) GetListValues

func (f *ForjFlag) GetListValues() []ForjData

func (*ForjFlag) GetStringAddr

func (f *ForjFlag) GetStringAddr() *string

func (*ForjFlag) GetStringValue

func (f *ForjFlag) GetStringValue() string

func (*ForjFlag) GetValue

func (f *ForjFlag) GetValue() interface{}

func (*ForjFlag) IsFound

func (f *ForjFlag) IsFound() bool

func (*ForjFlag) IsFromObject

func (f *ForjFlag) IsFromObject(obj *ForjObject) bool

func (*ForjFlag) IsList

func (f *ForjFlag) IsList() bool

func (*ForjFlag) Name

func (f *ForjFlag) Name() string

func (*ForjFlag) String

func (f *ForjFlag) String() (ret string)

func (*ForjFlag) Type

func (f *ForjFlag) Type() string

func (*ForjFlag) UpdateObject

func (f *ForjFlag) UpdateObject() error

type ForjFlagList

type ForjFlagList struct {
	// contains filtered or unexported fields
}

ForjFlagList defines the flag list structure for each object actions

func (*ForjFlagList) Copier

func (a *ForjFlagList) Copier() (p ForjParamCopier)

func (*ForjFlagList) CopyToArg

func (a *ForjFlagList) CopyToArg(cmd clier.CmdClauser) *ForjArg

func (*ForjFlagList) CopyToFlag

func (a *ForjFlagList) CopyToFlag(cmd clier.CmdClauser) *ForjFlag

func (*ForjFlagList) Default

func (f *ForjFlagList) Default(value string) ForjParam

func (*ForjFlagList) GetBoolAddr

func (f *ForjFlagList) GetBoolAddr() *bool

func (*ForjFlagList) GetBoolValue

func (f *ForjFlagList) GetBoolValue() bool

func (*ForjFlagList) GetContextValue

func (f *ForjFlagList) GetContextValue(context clier.ParseContexter) (interface{}, bool)

func (*ForjFlagList) GetFlagClauser

func (a *ForjFlagList) GetFlagClauser() clier.FlagClauser

func (*ForjFlagList) GetListValues

func (f *ForjFlagList) GetListValues() []ForjData

func (*ForjFlagList) GetStringAddr

func (f *ForjFlagList) GetStringAddr() *string

func (*ForjFlagList) GetStringValue

func (f *ForjFlagList) GetStringValue() string

func (*ForjFlagList) GetValue

func (f *ForjFlagList) GetValue() interface{}

func (*ForjFlagList) IsFound

func (f *ForjFlagList) IsFound() bool

func (*ForjFlagList) IsFromObject

func (f *ForjFlagList) IsFromObject(obj *ForjObject) bool

func (*ForjFlagList) IsList

func (f *ForjFlagList) IsList() bool

func (*ForjFlagList) Name

func (fl *ForjFlagList) Name() string

func (*ForjFlagList) String

func (f *ForjFlagList) String() (ret string)

func (*ForjFlagList) Type

func (f *ForjFlagList) Type() string

type ForjInstanceData

type ForjInstanceData map[string]interface{}

type ForjKingpinParam

type ForjKingpinParam interface {
	GetKFlag()
}

type ForjListData

type ForjListData struct {
	Data map[string]string
}

type ForjListParam

type ForjListParam interface {
	IsFound() bool
	GetAll() []ForjData
	IsList() bool
}

type ForjObject

type ForjObject struct {
	// contains filtered or unexported fields
}

ForjObject defines the Object structure

func (*ForjObject) AddArg

func (o *ForjObject) AddArg(name string, options *ForjOpts) *ForjObject

func (*ForjObject) AddField

func (o *ForjObject) AddField(pIntType, name, help, re string, opts *ForjOpts) *ForjObject

AddField add a field to the object.

func (*ForjObject) AddFlag

func (o *ForjObject) AddFlag(name string, options *ForjOpts) *ForjObject

AddFlag add a flag on the selected list of actions (OnActions)

func (*ForjObject) AddFlagFromObjectListAction

func (o *ForjObject) AddFlagFromObjectListAction(obj_name, obj_list, obj_action string) *ForjObject

AddFlagFromObjectListAction add flag on the select object selected action (OnActions) from object list actions identified by obj_name, obj_list, []obj_actions. The flag will be named as --<obj_action>-<obj_name>s

- obj_name, obj_list, obj_action identify the list and action to add as flag

- action where flags will be created.

ex: forjj create workspace --repos ...

At context time this object list will create more detailed flags.

return nil if the obj_list is not found. Otherwise, return the object updated.

func (*ForjObject) AddFlagsFromObjectAction

func (o *ForjObject) AddFlagsFromObjectAction(obj_name, obj_action string) *ForjObject

AddFlagsFromObjectAction will add all object action flags to the selected object actions.

func (*ForjObject) AddFlagsFromObjectListActions

func (o *ForjObject) AddFlagsFromObjectListActions(obj_name, obj_list string, obj_actions ...string) *ForjObject

AddFlagsFromObjectListActions add flags on the select object selected action (OnActions) from object list actions identified by obj_name, obj_list, []obj_actions. The flag will be named as --<obj_action>-<obj_name>s

- obj_name, obj_list, obj_action identify the list and action to add as flags

- action where flags will be created.

ex: forjj create --add-repos ...

At context time this object list will create more detailed flags.

return nil if the obj_list is not found. Otherwise, return the object updated.

func (*ForjObject) AddInstanceField

func (o *ForjObject) AddInstanceField(instance, pIntType, name, help, re string, opts *ForjOpts) *ForjObject

AddInstanceField add a field to the object.

func (*ForjObject) AddInstances

func (o *ForjObject) AddInstances(instances ...string) *ForjObject

AddInstanceField add a field to the object.

func (*ForjObject) AddKey

func (o *ForjObject) AddKey(pIntType, name, help, re string, opts *ForjOpts) *ForjObject

AddKey add a Key field to the object.

func (*ForjObject) CreateList

func (o *ForjObject) CreateList(name, list_sep, ext_regexp, help string) *ForjObjectList

CreateList create a new list. It returns the ForjObjectList to set it and configure actions

func (*ForjObject) DefineActions

func (o *ForjObject) DefineActions(actions ...string) *ForjObject

DefineActions add a new object and the list of actions. It creates the ForjAction object for each action/object couple, to attach the object to kingpin object layer.

func (*ForjObject) Error

func (o *ForjObject) Error() error

func (*ForjObject) GetInstances

func (o *ForjObject) GetInstances() []string

func (*ForjObject) HasField

func (o *ForjObject) HasField(field string) (res bool)

HasField return true if the field exists

func (*ForjObject) HasInstanceField

func (o *ForjObject) HasInstanceField(instance, field string) (res bool)

func (*ForjObject) HasRole

func (o *ForjObject) HasRole() string

IsInternal return the object scope, ie internal or not. Defined by the application initialization See NewObject()

func (*ForjObject) IsObjectField

func (o *ForjObject) IsObjectField(name string) (found bool, has_object_field bool)

func (*ForjObject) IsSingle

func (o *ForjObject) IsSingle() bool

func (*ForjObject) Name

func (o *ForjObject) Name() string

func (*ForjObject) NoFields

func (o *ForjObject) NoFields() *ForjObject

NoFields add a Key field to the object.

func (*ForjObject) OnActions

func (o *ForjObject) OnActions(list ...string) *ForjObject

OnActions select several actions from ObjectActions. If list is empty, used the declared object actions.

func (*ForjObject) OnInstance

func (o *ForjObject) OnInstance(instance_name string) *ForjObject

func (*ForjObject) ParseHook

func (o *ForjObject) ParseHook(context_hook func(*ForjObject, *ForjCli, interface{}) (error, bool)) *ForjObject

func (*ForjObject) SetParamOptions

func (o *ForjObject) SetParamOptions(param_name string, options *ForjOpts)

SetParamOptions update flag/arg options anywhere param_name has been defined, except flag/arg list.

func (*ForjObject) Single

func (o *ForjObject) Single() *ForjObject

func (*ForjObject) String

func (o *ForjObject) String() string

type ForjObjectAction

type ForjObjectAction struct {
	// contains filtered or unexported fields
}

ForjObjectAction defines the action structure for each object

Ex: forjj create =>repo --flags value ...<=

where repo is a cmd and params store all object flags/args

func (*ForjObjectAction) String

func (a *ForjObjectAction) String() string

type ForjObjectInstance

type ForjObjectInstance struct {
	// contains filtered or unexported fields
}

func NewObjectInstance

func NewObjectInstance(name string) *ForjObjectInstance

func (*ForjObjectInstance) String

func (i *ForjObjectInstance) String() string

type ForjObjectList

type ForjObjectList struct {
	// contains filtered or unexported fields
}

ForjObjectList defines a list to apply as new Cmd or as flags/args to any other objects/actions

Ex: forjj create =>repos instance1,instance2,... --<instance>-flags value ...<= identified by actions map[string]*ForjObjectAction.

or with ForjObjectListFlags

Ex: forjj create infra =>--repos instance1,instance2,... --<instance>-flags value ...<= identified by flags_list

func (*ForjObjectList) AddActions

func (l *ForjObjectList) AddActions(actions ...string) *ForjObjectList

AddActions Add the list actions. Ex: forjj add repos <blabla>.

`add` must be an existing action `repos` is a new object action with a cmd attached. `<blabla>` is a arg string that must be attached to the new object action.

The new object action is called with the referenced action to add action to. The Cmd is called `object_name` + `s`

The new Argument is called as `object_name` + `s`. In Cmd, it is called `object_name` + `s`

kingpin: The function creates a new command and an attached argument. The argument is managed by ForjObjectList.

It returns the base object. The list key value will be used at context time to add contexted flag prefixed by the key value.

func (*ForjObjectList) AddFlagsFromObjectAction

func (l *ForjObjectList) AddFlagsFromObjectAction(obj_name, obj_action string) *ForjObjectList

func (*ForjObjectList) AddValidateHandler

func (l *ForjObjectList) AddValidateHandler(valid_handler func(*ForjListData) error) *ForjObjectList

func (*ForjObjectList) IsCumulative

func (d *ForjObjectList) IsCumulative() bool

Inform kingpin that flag is cumulative.

func (*ForjObjectList) ParseHook

func (l *ForjObjectList) ParseHook(context_hook func(*ForjObjectList, *ForjCli, interface{}) (error, bool)) *ForjObjectList

func (*ForjObjectList) Set

func (l *ForjObjectList) Set(value string) error

Set function for kingpin.Value interface Accept only one call to Set. The last call win. Each call to this function re-initialize the context/final list

func (*ForjObjectList) String

func (d *ForjObjectList) String() string

func (*ForjObjectList) Stringer

func (d *ForjObjectList) Stringer() (ret string)

Stringer : Set function for kingpin.Value interface

type ForjObjectListFlags

type ForjObjectListFlags struct {
	// contains filtered or unexported fields
}

type ForjOpts

type ForjOpts struct {
	// contains filtered or unexported fields
}

func Opts

func Opts() *ForjOpts

func (*ForjOpts) Default

func (o *ForjOpts) Default(v string) *ForjOpts

func (*ForjOpts) Envar

func (o *ForjOpts) Envar(v string) *ForjOpts

func (*ForjOpts) GetDefault

func (o *ForjOpts) GetDefault(pType string) interface{}

GetDefault return the default value from defined options. Used to set single object attribute default value It must return a pointer to a pType value type (*string, *bool, ...)

func (*ForjOpts) HasEnvar

func (o *ForjOpts) HasEnvar() (bool, string)

func (*ForjOpts) IsRequired

func (o *ForjOpts) IsRequired() bool

func (*ForjOpts) MergeWith

func (o *ForjOpts) MergeWith(fromOpts *ForjOpts)

func (*ForjOpts) NoDefault

func (o *ForjOpts) NoDefault() *ForjOpts

func (*ForjOpts) NoEnvar

func (o *ForjOpts) NoEnvar() *ForjOpts

func (*ForjOpts) NoShort

func (o *ForjOpts) NoShort() *ForjOpts

func (*ForjOpts) NotRequired

func (o *ForjOpts) NotRequired() *ForjOpts

func (*ForjOpts) Required

func (o *ForjOpts) Required() *ForjOpts

func (*ForjOpts) Short

func (o *ForjOpts) Short(b byte) *ForjOpts

type ForjParam

type ForjParam interface {
	Name() string
	String() string
	Type() string
	IsFound() bool
	GetBoolValue() bool
	GetStringValue() string
	GetBoolAddr() *bool
	GetStringAddr() *string
	GetContextValue(clier.ParseContexter) (interface{}, bool)
	GetValue() interface{}
	// Update default
	Default(string) ForjParam

	IsList() bool

	IsFromObject(*ForjObject) bool

	CopyToFlag(clier.CmdClauser) *ForjFlag
	CopyToArg(clier.CmdClauser) *ForjArg

	Copier() ForjParamCopier
	// contains filtered or unexported methods
}

type ForjParamCopier

type ForjParamCopier interface {
	CopyToFlag(clier.CmdClauser) *ForjFlag
	CopyToArg(clier.CmdClauser) *ForjArg
}

type ForjRecords

type ForjRecords struct {
	// contains filtered or unexported fields
}

func (*ForjRecords) Get

func (r *ForjRecords) Get(key, param string) (ret interface{}, found bool, err error)

GetFrom, get the param value from the defined context. If no context exists, it tries to get from App Flag layer It search in action_object and then action. If the value context is a list, it moves to get it from the App layer directly.

func (*ForjRecords) String

func (r *ForjRecords) String() (ret string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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