Documentation
¶
Index ¶
- Variables
- type Category
- type Command
- type CommandType
- type CompletionContext
- type CompletionFunc
- type HandlerType
- type ListFilterFunc
- type Resource
- type Schema
- type SortableCommand
- type SortableCommands
- type SortableParam
- type SortableParams
- type ValidateFunc
- func ValidateDateTimeString() ValidateFunc
- func ValidateFileExists() ValidateFunc
- func ValidateIPv4Address() ValidateFunc
- func ValidateIPv4AddressWithPrefix() ValidateFunc
- func ValidateIPv4AddressWithPrefixOption() ValidateFunc
- func ValidateInIntValues(allows ...int) ValidateFunc
- func ValidateInStrValues(allows ...string) ValidateFunc
- func ValidateIntRange(min int, max int) ValidateFunc
- func ValidateIntSlice(validator ValidateFunc) ValidateFunc
- func ValidateMACAddress() ValidateFunc
- func ValidateMemberCD() ValidateFunc
- func ValidateMulti(validators ...ValidateFunc) ValidateFunc
- func ValidateSakuraID() ValidateFunc
- func ValidateSakuraShortID(digit int) ValidateFunc
- func ValidateStrLen(min int, max int) ValidateFunc
- func ValidateStringSlice(validator ValidateFunc) ValidateFunc
- type ValueHandlerFunc
- type ValueType
Constants ¶
This section is empty.
Variables ¶
var CommonParamCategory = &Category{ Key: "common", DisplayName: "Common options", Order: math.MaxInt32 - 30, }
var DefaultCommandCategory = &Category{ Key: "default", DisplayName: "", Order: math.MaxInt32, }
var DefaultParamCategory = &Category{ Key: "default", DisplayName: "Other options", Order: math.MaxInt32, }
var DefaultResourceCategory = &Category{ Key: "default", DisplayName: "", Order: math.MaxInt32, }
var FilterParamCategory = &Category{ Key: "filter", DisplayName: "Filter options", Order: math.MaxInt32 - 60, }
var InputParamCategory = &Category{ Key: "Input", DisplayName: "Input options", Order: math.MaxInt32 - 20, }
var LimitOffsetParamCategory = &Category{ Key: "limit-offset", DisplayName: "Limit/Offset options", Order: math.MaxInt32 - 50, }
var OutputParamCategory = &Category{ Key: "output", DisplayName: "Output options", Order: math.MaxInt32 - 10, }
var SortParamCategory = &Category{ Key: "sort", DisplayName: "Sort options", Order: math.MaxInt32 - 40, }
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct { Type CommandType Aliases []string Usage string ArgsUsage string Category string Order int Params map[string]*Schema ParamCategories []Category AltResource string // 空の場合はResourceのキーをCamelizeしてsacloud.XXXを対象とする。 ListResultFieldName string SkipAuth bool SkipAfterSecondArgs bool // trueの場合、2番目以降の引数(1番目はID or 名称)の解析を行わない UseCustomCommand bool UseCustomArgCompletion bool UseCustomFlagsCompletion bool NeedlessConfirm bool ConfirmMessage string NoOutput bool NoSelector bool // --selectorオプション利用有無、trueの場合利用しない TableType output.TableType IncludeFields []string // for output.TableDetail ExcludeFields []string // for output.TableDetail TableColumnDefines []output.ColumnDef // for output.TableSimple }
func (*Command) BuildedParams ¶ added in v0.0.2
func (c *Command) BuildedParams() SortableParams
func (*Command) ParamCategory ¶
type CommandType ¶
type CommandType int //go:generate stringer -type=CommandType :: manual
CommandType is an enum of the type that can be represented by a schema.
const ( CommandInvalid CommandType = iota CommandList CommandCreate CommandRead CommandUpdate CommandDelete CommandManipulateMulti CommandManipulateSingle CommandManipulateIDOnly CommandCustom )
func (CommandType) CanUseSelector ¶ added in v0.0.13
func (c CommandType) CanUseSelector() bool
CanUseSelector タグなどでのセレクターが利用可能なコマンドタイプであるか
func (CommandType) IsNeedConfirmType ¶ added in v0.0.2
func (c CommandType) IsNeedConfirmType() bool
IsNeedConfirmType コマンド実行時に確認ダイアログが必要なコマンドタイプであるか
func (CommandType) IsNeedIDOnlyType ¶ added in v0.0.2
func (c CommandType) IsNeedIDOnlyType() bool
IsNeedIDOnlyType 引数にIDのみ受け付けるコマンドタイプであるか
func (CommandType) IsNeedSingleIDType ¶ added in v0.0.2
func (c CommandType) IsNeedSingleIDType() bool
IsNeedSingleIDType 引数に単一の対象リソースを要求するコマンドタイプであるか
func (CommandType) IsRequiredIDType ¶
func (c CommandType) IsRequiredIDType() bool
IsRequiredIDType 引数に対象リソースの指定を要求するコマンドタイプであるか
func (CommandType) String ¶
func (i CommandType) String() string
type CompletionContext ¶
type CompletionFunc ¶ added in v0.0.9
type CompletionFunc func(ctx CompletionContext, currentValue string) []string
func CompleteInIntValues ¶ added in v0.0.2
func CompleteInIntValues(values ...int) CompletionFunc
func CompleteInStrValues ¶ added in v0.0.2
func CompleteInStrValues(values ...string) CompletionFunc
type HandlerType ¶
type HandlerType int //go:generate stringer -type=HandlerType :: manual
HandlerType is an enum of the type that can be represented by a schema.
const ( HandlerPathThrough HandlerType = iota HandlerPathThroughEach HandlerSort HandlerFilterBy HandlerAndParams HandlerOrParams HandlerCustomFunc HandlerFilterFunc HandlerNoop )
func (HandlerType) CanSetDestinationProp ¶
func (h HandlerType) CanSetDestinationProp() bool
CanSetDestinationProp return true when HandlerType is able to have DestinationProp
func (HandlerType) IsNeedSliceValue ¶
func (h HandlerType) IsNeedSliceValue() bool
IsNeedSliceValue return true when HandlerType is need Slice ValueType
func (HandlerType) IsWhenListOnly ¶
func (h HandlerType) IsWhenListOnly() bool
IsWhenListOnly return true when HandlerType is able to use with CommandList
func (HandlerType) String ¶
func (i HandlerType) String() string
type ListFilterFunc ¶ added in v0.0.10
type ListFilterFunc func(list []interface{}, item interface{}, param interface{}) bool
type Resource ¶
type Resource struct { Aliases []string Usage string Commands map[string]*Command DefaultCommand string // 空の場合は`resource -h` AltResource string // 空の場合はResourceのキーをCamelizeしてsacloud.XXXを対象とする。 ListResultFieldName string CommandCategories []Category ResourceCategory Category SkipApplyConfigFile bool }
func (*Resource) CommandCategory ¶
func (*Resource) SortedCommands ¶
func (r *Resource) SortedCommands() SortableCommands
type Schema ¶
type Schema struct { Type ValueType DefaultValue interface{} DefaultText string EnvVars []string InputDefault interface{} Aliases []string Description string // Usage -> cli Hidden bool Category string Order int Required bool SakuraID bool ConflictsWith []string ValidateFunc ValidateFunc MaxItems int MinItems int HandlerType HandlerType DestinationProp string CustomHandler ValueHandlerFunc FilterFunc ListFilterFunc CompleteFunc CompletionFunc }
type SortableCommand ¶
type SortableCommands ¶
type SortableCommands []SortableCommand
func (SortableCommands) Len ¶
func (s SortableCommands) Len() int
func (SortableCommands) Less ¶
func (s SortableCommands) Less(i, j int) bool
func (SortableCommands) Swap ¶
func (s SortableCommands) Swap(i, j int)
type SortableParam ¶
type SortableParams ¶
type SortableParams []SortableParam
func (SortableParams) Get ¶ added in v0.0.13
func (s SortableParams) Get(key string) *SortableParam
func (SortableParams) Len ¶
func (s SortableParams) Len() int
func (SortableParams) Less ¶
func (s SortableParams) Less(i, j int) bool
func (SortableParams) Swap ¶
func (s SortableParams) Swap(i, j int)
type ValidateFunc ¶ added in v0.0.9
func ValidateDateTimeString ¶ added in v0.0.2
func ValidateDateTimeString() ValidateFunc
func ValidateFileExists ¶ added in v0.0.2
func ValidateFileExists() ValidateFunc
func ValidateIPv4Address ¶ added in v0.0.2
func ValidateIPv4Address() ValidateFunc
func ValidateIPv4AddressWithPrefix ¶ added in v0.0.9
func ValidateIPv4AddressWithPrefix() ValidateFunc
func ValidateIPv4AddressWithPrefixOption ¶ added in v0.0.9
func ValidateIPv4AddressWithPrefixOption() ValidateFunc
func ValidateInIntValues ¶ added in v0.0.2
func ValidateInIntValues(allows ...int) ValidateFunc
func ValidateInStrValues ¶ added in v0.0.2
func ValidateInStrValues(allows ...string) ValidateFunc
func ValidateIntRange ¶ added in v0.0.2
func ValidateIntRange(min int, max int) ValidateFunc
func ValidateIntSlice ¶ added in v0.0.2
func ValidateIntSlice(validator ValidateFunc) ValidateFunc
func ValidateMACAddress ¶ added in v0.0.9
func ValidateMACAddress() ValidateFunc
func ValidateMemberCD ¶ added in v0.0.2
func ValidateMemberCD() ValidateFunc
func ValidateMulti ¶ added in v0.0.2
func ValidateMulti(validators ...ValidateFunc) ValidateFunc
func ValidateSakuraID ¶ added in v0.0.2
func ValidateSakuraID() ValidateFunc
func ValidateSakuraShortID ¶ added in v0.0.2
func ValidateSakuraShortID(digit int) ValidateFunc
func ValidateStrLen ¶ added in v0.0.2
func ValidateStrLen(min int, max int) ValidateFunc
func ValidateStringSlice ¶ added in v0.0.2
func ValidateStringSlice(validator ValidateFunc) ValidateFunc
type ValueHandlerFunc ¶ added in v0.0.9
type ValueHandlerFunc func(name string, src interface{}, dest interface{})
type ValueType ¶
type ValueType int //go:generate stringer -type=ValueType :: manual
ValueType is an enum of the type that can be represented by a schema.
func (ValueType) IsSliceType ¶
IsSliceType return true if type is TypeIntList or TypeStringList