Documentation ¶
Index ¶
- Constants
- Variables
- func BuildFlagsUsage(cmd *cobra.Command, sets []*FlagSet)
- func BuildRootCommandsUsage(cmd *cobra.Command, commands []*CategorizedResources)
- type CategorizedCommands
- type CategorizedResources
- type Category
- type Command
- func (c *Command) CLICommand() *cobra.Command
- func (c *Command) CompleteArgs(ctx cli.Context, cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)
- func (c *Command) ParameterCategoryBy(key string) *Category
- func (c *Command) Run(ctx cli.Context, cmd *cobra.Command, args []string) error
- func (c *Command) ValidateSchema() error
- type ExampleHolder
- type FlagInitializer
- type FlagSet
- type FlagValueCleaner
- type IDFlag
- type IDSliceFlag
- type ParameterCustomizer
- type Progress
- type Resource
- type Resources
- type SelectorType
- type ValidateFunc
Constants ¶
View Source
const ( SelectorTypeNone = iota // セレクタなし(List系/自前実装系など) SelectorTypeRequireSingle // ID or Name or Tagsを受け取る(複数ヒットNG) SelectorTypeRequireMulti // ID or Name or Tagsを受け取る(複数ヒットOK) )
Variables ¶
View Source
var ( ResourceCategoryConfig = Category{ Key: "config", DisplayName: "Configuration", Order: 10, } ResourceCategoryAuth = Category{ Key: "auth", DisplayName: "Authentication", Order: 20, } ResourceCategoryComputing = Category{ Key: "computing", DisplayName: "Computing", Order: 30, } ResourceCategoryStorage = Category{ Key: "storage", DisplayName: "Storage", Order: 40, } ResourceCategoryNetworking = Category{ Key: "networking", DisplayName: "Networking", Order: 50, } ResourceCategoryNetworkingSub = Category{ Key: "networking-sub", DisplayName: "Networking(SubResources)", Order: 55, } ResourceCategoryAppliance = Category{ Key: "appliance", DisplayName: "Appliance", Order: 60, } ResourceCategorySecureMobile = Category{ Key: "securemobile", DisplayName: "SecureMobile", Order: 70, } ResourceCategoryCommonServiceItem = Category{ Key: "commonserviceitem", DisplayName: "Common service items", Order: 80, } ResourceCategoryCommonItem = Category{ Key: "commonitem", DisplayName: "Common items", Order: 90, } ResourceCategoryBilling = Category{ Key: "billing", DisplayName: "Billing", Order: 100, } ResourceCategoryLab = Category{ Key: "lab", DisplayName: "Lab", Order: 110, } ResourceCategoryWebAccel = Category{ Key: "webaccel", DisplayName: "WebAccelerator", Order: 120, } ResourceCategoryMisc = Category{ Key: "misc", DisplayName: "Other services", Order: 130, } ResourceCategoryZone = Category{ Key: "zone", DisplayName: "Region/Zone information", Order: 140, } ResourceCategoryInformation = Category{ Key: "information", DisplayName: "Service/Product information", Order: 150, } ResourceCategoryOther = Category{ Key: "other", DisplayName: "Other commands", Order: 160, } ResourceCategories = []Category{ ResourceCategoryConfig, ResourceCategoryAuth, ResourceCategoryComputing, ResourceCategoryStorage, ResourceCategoryNetworking, ResourceCategoryNetworkingSub, ResourceCategoryAppliance, ResourceCategorySecureMobile, ResourceCategoryCommonServiceItem, ResourceCategoryCommonItem, ResourceCategoryBilling, ResourceCategoryLab, ResourceCategoryWebAccel, ResourceCategoryMisc, ResourceCategoryZone, ResourceCategoryInformation, ResourceCategoryOther, } )
View Source
var CommandCategories = []Category{
{
Key: "basic",
DisplayName: "Basic Commands",
Order: 100,
},
{
Key: "connect",
DisplayName: "Connect Commands",
Order: 150,
},
{
Key: "operation",
DisplayName: "Operation Commands",
Order: 200,
},
{
Key: "subnet",
DisplayName: "Subnet Operation Commands",
Order: 210,
},
{
Key: "ipv6",
DisplayName: "IPv6 Operation Commands",
Order: 211,
},
{
Key: "certificate",
DisplayName: "Certificate Management Commands",
Order: 220,
},
{
Key: "cache",
DisplayName: "Cache Management Commands",
Order: 221,
},
{
Key: "power",
DisplayName: "Power Management Commands",
Order: 250,
},
{
Key: "backup",
DisplayName: "Backup Commands",
Order: 300,
},
{
Key: "monitor",
DisplayName: "Monitoring Commands",
Order: 500,
},
{
Key: "other",
DisplayName: "Other Commands",
Order: 10000,
},
}
View Source
var ParameterCategories = []*Category{ { Key: "common", DisplayName: "Common options", Order: 50, }, { Key: "plan", DisplayName: "Plan options", Order: 60, }, { Key: "diskedit", DisplayName: "Edit disk options", Order: 200, }, { Key: "network", DisplayName: "Network options", Order: 200, }, { Key: "health", DisplayName: "Health check options", Order: 200, }, { Key: "filter", DisplayName: "Filter options", Order: math.MaxInt32 - 100, }, { Key: "limit-offset", DisplayName: "Limit/Offset options", Order: math.MaxInt32 - 90, }, { Key: "sort", DisplayName: "Sort options", Order: math.MaxInt32 - 80, }, { Key: "monitor", DisplayName: "Monitor options", Order: math.MaxInt32 - 70, }, { Key: "delete", DisplayName: "Delete options", Order: math.MaxInt32 - 60, }, { Key: "zone", DisplayName: "Zone options", Order: math.MaxInt32 - 50, }, { Key: "error", DisplayName: "Error handling options", Order: math.MaxInt32 - 40, }, { Key: "wait", DisplayName: "Wait options", Order: math.MaxInt32 - 30, }, { Key: "input", DisplayName: "Input options", Order: math.MaxInt32 - 20, }, { Key: "output", DisplayName: "Output options", Order: math.MaxInt32 - 10, }, { Key: "example", DisplayName: "Parameter example", Order: math.MaxInt32 - 5, }, { Key: "default", DisplayName: "Other options", Order: math.MaxInt32, }, }
Functions ¶
func BuildFlagsUsage ¶
func BuildRootCommandsUsage ¶
func BuildRootCommandsUsage(cmd *cobra.Command, commands []*CategorizedResources)
Types ¶
type CategorizedCommands ¶
type CategorizedResources ¶
type Command ¶
type Command struct { Name string // コマンド名、ケバブケース(ハイフン区切り)で指定すること Aliases []string // エイリアス Usage string ArgsUsage string // Argumentsの説明、省略した場合はSelectorTypeの値に応じた内容が設定される Category string // カテゴリーのキー Order int // コマンドが属するリソース内での並び順 // コマンド動作関連 SelectorType SelectorType NoProgress bool // コマンド実行時のプログレス表示の有無 ConfirmMessage string // パラメータ関連 ParameterCategories []Category ParameterInitializer func() interface{} ServiceFuncAltName string // デフォルトのlibsacloud service呼び出しコード生成用、空の場合はNameをCamelizeしたものが利用される // TODO libsacloud側で対応すべき // テーブル形式での出力対象列。省略した場合はIDとNameが出力される ColumnDefs []output.ColumnDef // TODO そのうちDeprecatedWarningとかも対応する ExperimentWarning string // 操作対象リソースの一覧取得用。通常はResourceに紐づけられたfuncを利用する ListAllFunc func(ctx cli.Context, parameter interface{}) ([]interface{}, error) // 特殊な引数補完をしたい場合に設定する CustomCompletionFunc func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) // カスタムバリデーション用。空の場合usacloud/pkg/validate.Execが実行される ValidateFunc ValidateFunc // コマンドの実処理。設定してない場合はデフォルトのlibsacloud service呼び出しが行われる Func func(ctx cli.Context, parameter interface{}) ([]interface{}, error) // contains filtered or unexported fields }
Command コマンド定義、実行時のコンテキスト(設定保持)にもなる
func (*Command) CLICommand ¶
func (*Command) CompleteArgs ¶
func (*Command) ParameterCategoryBy ¶
func (*Command) ValidateSchema ¶
type ExampleHolder ¶
type FlagInitializer ¶
type FlagValueCleaner ¶
type IDSliceFlag ¶
func NewIDSliceFlag ¶
func NewIDSliceFlag(val *[]types.ID, p *[]types.ID) *IDSliceFlag
func (*IDSliceFlag) Set ¶
func (v *IDSliceFlag) Set(ids string) error
func (*IDSliceFlag) String ¶
func (v *IDSliceFlag) String() string
func (*IDSliceFlag) Type ¶
func (v *IDSliceFlag) Type() string
type ParameterCustomizer ¶
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
func NewProgress ¶
type Resource ¶
type Resource struct { Name string Aliases []string Usage string DefaultCommandName string Category Category Warning string IsGlobalResource bool ServiceType reflect.Type // リソースに対応するlibsacloud serviceの型情報、コード生成用 SkipLoadingProfile bool // contains filtered or unexported fields }
func (*Resource) AddCommand ¶
func (*Resource) CLICommand ¶
func (*Resource) CategorizedCommands ¶
func (r *Resource) CategorizedCommands() []*CategorizedCommands
type Resources ¶
type Resources []*Resource
func (Resources) CategorizedResources ¶
func (r Resources) CategorizedResources() []*CategorizedResources
type SelectorType ¶
type SelectorType int
type ValidateFunc ¶
Source Files ¶
- categorized.go
- category.go
- command.go
- command_categories.go
- completion.go
- customize_parameter.go
- example.go
- flag_value.go
- flagset.go
- mapconv.go
- parameter_categories.go
- parameter_loader.go
- progress.go
- resource.go
- resource_categories.go
- resources.go
- run.go
- skeleton.go
- update_self.go
- usage.go
- warning.go
Click to show internal directories.
Click to hide internal directories.