command

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultZone       = "tk1a"
	DefaultOutputType = "table"
)
View Source
var GlobalFlags = []cli.Flag{
	&cli.StringFlag{
		Name:        "token",
		Usage:       "API Token of SakuraCloud",
		EnvVars:     []string{"SAKURACLOUD_ACCESS_TOKEN"},
		DefaultText: "none",
		Destination: &GlobalOption.AccessToken,
	},
	&cli.StringFlag{
		Name:        "secret",
		Usage:       "API Secret of SakuraCloud",
		EnvVars:     []string{"SAKURACLOUD_ACCESS_TOKEN_SECRET"},
		DefaultText: "none",
		Destination: &GlobalOption.AccessTokenSecret,
	},
	&cli.StringFlag{
		Name:        "zone",
		Usage:       "Target zone of SakuraCloud",
		EnvVars:     []string{"SAKURACLOUD_ZONE"},
		Value:       DefaultZone,
		DefaultText: DefaultZone,
		Destination: &GlobalOption.Zone,
	},
	&cli.StringFlag{
		Name:        "config",
		Aliases:     []string{"profile"},
		Usage:       "Config(Profile) name",
		EnvVars:     []string{"USACLOUD_PROFILE"},
		Destination: &GlobalOption.ProfileName,
	},
	&cli.IntFlag{
		Name:        "timeout",
		Usage:       "Number of timeout minutes for polling functions",
		EnvVars:     []string{"SAKURACLOUD_TIMEOUT"},
		Value:       20,
		Destination: &GlobalOption.Timeout,
	},
	&cli.StringFlag{
		Name:        "accept-language",
		Usage:       "Accept-Language Header",
		EnvVars:     []string{"SAKURACLOUD_ACCEPT_LANGUAGE"},
		Destination: &GlobalOption.AcceptLanguage,
	},
	&cli.IntFlag{
		Name:        "retry-max",
		Usage:       "Number of API-Client retries",
		EnvVars:     []string{"SAKURACLOUD_RETRY_MAX"},
		Destination: &GlobalOption.RetryMax,
	},
	&cli.Int64Flag{
		Name:        "retry-interval",
		Usage:       "API client retry interval seconds",
		EnvVars:     []string{"SAKURACLOUD_RETRY_INTERVAL"},
		Destination: &GlobalOption.RetryIntervalSec,
	},
	&cli.BoolFlag{
		Name:        "no-color",
		Usage:       "Flag of not using ANSI color output",
		EnvVars:     []string{"NO_COLOR"},
		Destination: &GlobalOption.NoColor,
	},
	&cli.StringFlag{
		Name:        "api-root-url",
		EnvVars:     []string{"USACLOUD_API_ROOT_URL"},
		Destination: &GlobalOption.APIRootURL,
		Hidden:      true,
	},
	&cli.StringFlag{
		Name:        "default-output-type",
		EnvVars:     []string{"USACLOUD_DEFAULT_OUTPUT_TYPE"},
		Destination: &GlobalOption.DefaultOutputType,
		Value:       DefaultOutputType,
		Hidden:      true,
	},
	&cli.StringSliceFlag{
		Name:   "zones",
		Hidden: true,
	},
	&cli.BoolFlag{
		Name:        "trace",
		Usage:       "Flag of SakuraCloud debug-mode",
		EnvVars:     []string{"SAKURACLOUD_TRACE_MODE"},
		Destination: &GlobalOption.TraceMode,
		Value:       false,
		Hidden:      true,
	},
}
View Source
var GlobalOption = &Option{
	In:       os.Stdin,
	Out:      colorable.NewColorableStdout(),
	Progress: colorable.NewColorableStderr(),
	Err:      colorable.NewColorableStderr(),
}

Functions

func Confirm added in v0.0.11

func Confirm(msg string) bool

func ConfirmContinue added in v0.0.11

func ConfirmContinue(target string, ids ...int64) bool

func FlattenErrors added in v0.0.11

func FlattenErrors(errors []error) error

func FlattenErrorsWithPrefix added in v0.0.11

func FlattenErrorsWithPrefix(errors []error, pref string) error

func GetParamTemplateValue added in v0.0.11

func GetParamTemplateValue(o InputOption) (string, error)

func IsEmpty added in v0.0.11

func IsEmpty(object interface{}) bool

IsEmpty is copied from github.com/stretchr/testify/assert/assetions.go

func StringIDs

func StringIDs(ids []int64) []string

func UniqIDs added in v0.0.11

func UniqIDs(elements []int64) []int64

func ValidateBetween added in v0.0.11

func ValidateBetween(fieldName string, object interface{}, min int, max int) []error

func ValidateConflictValues added in v0.0.11

func ValidateConflictValues(fieldName string, object interface{}, values map[string]interface{}) []error

func ValidateConflicts added in v0.0.11

func ValidateConflicts(fieldName string, object interface{}, values map[string]interface{}) []error

func ValidateExistsFileOrStdIn added in v0.7.0

func ValidateExistsFileOrStdIn(fieldName string, object interface{}) []error

func ValidateIPv4Address added in v0.3.0

func ValidateIPv4Address(fieldName string, object interface{}) []error

func ValidateIPv6Address added in v0.3.0

func ValidateIPv6Address(fieldName string, object interface{}) []error

func ValidateInStrValues added in v0.0.11

func ValidateInStrValues(fieldName string, object interface{}, allowValues ...string) []error

func ValidateInputOption added in v0.0.11

func ValidateInputOption(o InputOption) []error

func ValidateOutputOption added in v0.0.11

func ValidateOutputOption(o output.Option) []error

func ValidateRequired added in v0.0.11

func ValidateRequired(fieldName string, object interface{}) []error

func ValidateSakuraID added in v0.0.11

func ValidateSakuraID(fieldName string, object interface{}) []error

func ValidateSetProhibited added in v0.0.11

func ValidateSetProhibited(fieldName string, object interface{}) []error

Types

type Context

type Context interface {
	GetOutput() output.Output
	GetAPIClient() *api.Client
	Args() []string
	NArgs() int
	FlagContext
}

func NewContext

func NewContext(flagContext FlagContext, args []string, formater interface{}) Context

type FlagContext

type FlagContext interface {
	IsSet(name string) bool
}

type InputOption added in v0.0.11

type InputOption interface {
	GetParamTemplate() string
	GetParamTemplateFile() string
}

type Option

type Option struct {
	AccessToken       string
	AccessTokenSecret string
	Zone              string
	ProfileName       string
	Timeout           int
	AcceptLanguage    string
	RetryMax          int
	RetryIntervalSec  int64
	Zones             []string
	APIRootURL        string
	TraceMode         bool
	Format            string
	DefaultOutputType string
	NoColor           bool
	In                *os.File
	Out               io.Writer
	Progress          io.Writer
	Err               io.Writer
	Validated         bool
	Valid             bool
	ValidationResults []error
}

func (*Option) Validate

func (o *Option) Validate(skipAuth bool) []error

type OutputTypeHolder added in v0.6.0

type OutputTypeHolder interface {
	GetOutputType() string
	SetOutputType(string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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