core

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

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 LabelsExtractors []func(v interface{}) *Labels

Functions

func BuildFlagsUsage

func BuildFlagsUsage(cmd *cobra.Command, sets []*FlagSet)

func SetSubCommandsUsage

func SetSubCommandsUsage(cmd *cobra.Command, commands []*CategorizedResources)

Types

type CategorizedCommands

type CategorizedCommands struct {
	Category category.Category
	Commands []*Command
}

type CategorizedResources

type CategorizedResources struct {
	Category  category.Category
	Resources []*Resource
}

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.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 (c *Command) CLICommand() *cobra.Command

func (*Command) CompleteArgs

func (c *Command) CompleteArgs(ctx cli.Context, cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

func (*Command) ParameterCategoryBy

func (c *Command) ParameterCategoryBy(key string) *category.Category

func (*Command) Run

func (c *Command) Run(ctx cli.Context, cmd *cobra.Command, args []string) error

func (*Command) ValidateSchema

func (c *Command) ValidateSchema() error

type ExampleHolder

type ExampleHolder interface {
	ExampleParameters(ctx cli.Context) interface{}
}

type FlagInitializer

type FlagInitializer interface {
	SetupCobraCommandFlags(cmd *cobra.Command)
}

type FlagSet

type FlagSet struct {
	Title string
	Flags *pflag.FlagSet
}

type FlagValueCleaner

type FlagValueCleaner interface {
	CleanupEmptyValue(flags *pflag.FlagSet)
}

type IDFlag

type IDFlag types.ID

func NewIDFlag

func NewIDFlag(val *types.ID, p *types.ID) *IDFlag

func (*IDFlag) Set

func (v *IDFlag) Set(id string) error

func (*IDFlag) String

func (v *IDFlag) String() string

func (*IDFlag) Type

func (v *IDFlag) Type() string

type IDSliceFlag

type IDSliceFlag []types.ID

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 Labels

type Labels struct {
	Id   string
	Name string
	Tags []string
}

Labels Usacloudで扱うリソースを識別するためのラベル情報

シェル補完や引数をID or Name or Tagsにマッチさせるために利用される

type ParameterCustomizer

type ParameterCustomizer interface {
	Customize(ctx cli.Context) error
}

type Progress

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

func NewProgress

func NewProgress(ctx cli.Context) *Progress

func (*Progress) Close

func (p *Progress) Close()

func (*Progress) Exec

func (p *Progress) Exec(f func() error) error

func (*Progress) Start

func (p *Progress) Start()

type Resource

type Resource struct {
	Name               string
	Aliases            []string
	Usage              string
	DefaultCommandName string
	Category           category.Category
	Warning            string
	IsGlobalResource   bool
	PlatformName       string       // "iaas" or "phy" or "objectstorage", 空の場合はIaaSとして扱われる
	ServiceType        reflect.Type // リソースに対応するserviceの型情報、コード生成用
	SkipLoadingProfile bool
	// contains filtered or unexported fields
}

func (*Resource) AddChild

func (r *Resource) AddChild(resource *Resource)

func (*Resource) AddCommand

func (r *Resource) AddCommand(command *Command)

func (*Resource) CLICommand

func (r *Resource) CLICommand() *cobra.Command

func (*Resource) CategorizedCommands

func (r *Resource) CategorizedCommands() []*CategorizedCommands

func (*Resource) Children

func (r *Resource) Children() []*Resource

func (*Resource) Commands

func (r *Resource) Commands() []*Command

func (*Resource) FullName

func (r *Resource) FullName() string

func (*Resource) Parent

func (r *Resource) Parent() *Resource

type Resources

type Resources []*Resource

func (Resources) CategorizedResources

func (r Resources) CategorizedResources(categories []category.Category) []*CategorizedResources

CategorizedResources categoriesと各リソースのカテゴリー名を用いてカテゴリー配下にリソースを紐づけて返す

type SelectorType

type SelectorType int

type ValidateFunc

type ValidateFunc func(ctx cli.Context, parameter interface{}) error

Jump to

Keyboard shortcuts

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