command

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Remote string // git remote name for erda repo

	Interactive  bool
	IsCompletion bool
)
View Source
var ConfigVersion string = "v0.0.1"
View Source
var RootCmd = &cobra.Command{
	Use:   "erda-cli",
	Short: "Erda commandline client",
	Long: `
    _/_/_/_/       _/_/_/        _/_/_/          _/_/    
   _/             _/    _/      _/    _/      _/    _/   
  _/_/_/         _/_/_/        _/    _/      _/_/_/_/    
 _/             _/    _/      _/    _/      _/    _/     
_/_/_/_/       _/    _/      _/_/_/        _/    _/      
`,
	SilenceUsage:      true,
	PersistentPreRunE: PrepareCtx,
}

rootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func PrepareCtx

func PrepareCtx(cmd *cobra.Command, args []string) error

func SetProjectConfig

func SetProjectConfig(file string, conf *ProjectInfo) error

Types

type ApplicationInfo

type ApplicationInfo struct {
	Application   string `yaml:"name"`
	ApplicationID uint64 `yaml:"id"`
	Mode          string `yaml:"mode"`
	Desc          string `yaml:"desc"`
	Sonarhost     string `yaml:"sonarhost"`
	Sonartoken    string `yaml:"sonartoken"`
	Sonarproject  string `yaml:"sonarproject"`
}

type Arg

type Arg interface {
	Validate(idx int, src string) error
	// return (converted_value, type_string)
	Convert(src string) interface{}
	// return converted_value_type_string
	ConvertType() string
	GetName() string
	// set name
	Name(name string) Arg
	// is an optional arg?
	Option() Arg

	IsOption() bool
}

type BaseResponse

type BaseResponse struct {
	Success bool            `json:"success"`
	Data    json.RawMessage `json:"data"`
	Err     interface{}     `json:"err"`
}

type BoolFlag

type BoolFlag struct {
	Short        string
	Name         string
	Doc          string
	DefaultValue bool
}

func (BoolFlag) DefaultV

func (v BoolFlag) DefaultV() string

func (BoolFlag) Flag

func (BoolFlag) Flag()

type Command

type Command struct {
	// default: rootcmd
	ParentName string
	Name       string
	ShortHelp  string
	LongHelp   string
	Example    string
	// dont show up in list of cmds
	Hidden         bool
	DontHideCursor bool
	/* args:
	        []Arg {
		       IPArg{},
		       StringArg{},
		       BoolArg{},
		}
	*/
	Args []Arg
	/* flags:
	        []Flag{
	                StringFlag{"H", "host", "1.2.3.4", "doc"},
	                BoolFlag{"A", "another", true, "doc"},
	                IntFlag{"O", "ohyoyo", 1, "doc"},
		}
	*/
	MarkFlagRequired           []string
	RegisterFlagCompletionFunc map[string]interface{}
	ValidArgsFunction          interface{}
	Flags                      []Flag
	/* actually type:
		func(ctx Context, arg1 IPArg, arg2 string, arg3 bool, host string, anotherone bool, ohyoyo int) error

	`host`, `anotherone`, `ohyoyo` is generated by `Flags`
	*/
	Run interface{}
}

type CommonArg

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

func (CommonArg) GetName

func (a CommonArg) GetName() string

func (CommonArg) IsOption

func (a CommonArg) IsOption() bool

type Context

type Context struct {
	Sessions           map[string]status.StatusInfo
	CurrentHost        string
	Domain             *url.URL
	Openapi            *url.URL
	Hepaapi            *url.URL
	CurrentOrg         OrgInfo
	CurrentProject     ProjectInfo
	CurrentApplication ApplicationInfo
	Applications       []ApplicationInfo
	Debug              bool
	Token              string // uc token
	HttpClient         *httpclient.HTTPClient
}

func GetContext

func GetContext() *Context

func (*Context) Delete

func (ctx *Context) Delete() *httpclient.Request

func (*Context) Error

func (ctx *Context) Error(format string, a ...interface{})

func (*Context) Fail

func (ctx *Context) Fail(format string, a ...interface{})

func (*Context) FetchOpenapi

func (ctx *Context) FetchOpenapi() error

func (*Context) FetchOrgs

func (ctx *Context) FetchOrgs() error

func (*Context) Get

func (ctx *Context) Get() *httpclient.Request

func (*Context) GetUserID

func (ctx *Context) GetUserID() string

func (*Context) Info

func (ctx *Context) Info(format string, a ...interface{})

func (*Context) Patch

func (ctx *Context) Patch() *httpclient.Request

func (*Context) Post

func (ctx *Context) Post() *httpclient.Request

func (*Context) Put

func (ctx *Context) Put() *httpclient.Request

func (*Context) Succ

func (ctx *Context) Succ(format string, a ...interface{})

func (*Context) UseDomain

func (ctx *Context) UseDomain() *Context

func (*Context) UseHepaApi

func (ctx *Context) UseHepaApi() *Context

func (*Context) UseOpenapi

func (ctx *Context) UseOpenapi() *Context

func (*Context) Warn

func (ctx *Context) Warn(format string, a ...interface{})

type Flag

type Flag interface {
	Flag()
	DefaultV() string
}

type FloatArg

type FloatArg struct {
	CommonArg
}

func (FloatArg) Convert

func (FloatArg) Convert(src string) interface{}

func (FloatArg) ConvertType

func (FloatArg) ConvertType() string

func (FloatArg) Name

func (a FloatArg) Name(name string) Arg

func (FloatArg) Option

func (a FloatArg) Option() Arg

func (FloatArg) Validate

func (FloatArg) Validate(idx int, src string) error

type FloatFlag

type FloatFlag struct {
	Short        string
	Name         string
	Doc          string
	DefaultValue float64
}

func (FloatFlag) DefaultV

func (v FloatFlag) DefaultV() string

func (FloatFlag) Flag

func (FloatFlag) Flag()

type IPArg

type IPArg struct {
	CommonArg
}

func (IPArg) Convert

func (IPArg) Convert(src string) interface{}

func (IPArg) ConvertType

func (IPArg) ConvertType() string

func (IPArg) Name

func (a IPArg) Name(name string) Arg

func (IPArg) Option

func (a IPArg) Option() Arg

func (IPArg) Validate

func (IPArg) Validate(idx int, src string) error

type IPFlag

type IPFlag struct {
	Short        string
	Name         string
	Doc          string
	DefaultValue string
}

func (IPFlag) DefaultV

func (v IPFlag) DefaultV() string

func (IPFlag) Flag

func (IPFlag) Flag()

type IntArg

type IntArg struct {
	CommonArg
}

func (IntArg) Convert

func (IntArg) Convert(src string) interface{}

func (IntArg) ConvertType

func (IntArg) ConvertType() string

func (IntArg) Name

func (a IntArg) Name(name string) Arg

func (IntArg) Option

func (a IntArg) Option() Arg

func (IntArg) Validate

func (IntArg) Validate(idx int, src string) error

type IntFlag

type IntFlag struct {
	Short        string
	Name         string
	Doc          string
	DefaultValue int
}

func (IntFlag) DefaultV

func (v IntFlag) DefaultV() string

func (IntFlag) Flag

func (IntFlag) Flag()

type Level2

type Level2 struct {
	V [2]string
}

func (Level2) DicePathAble

func (Level2) DicePathAble()

type Level2Arg

type Level2Arg struct {
	CommonArg
}

func (Level2Arg) Convert

func (Level2Arg) Convert(src string) interface{}

func (Level2Arg) ConvertType

func (Level2Arg) ConvertType() string

func (Level2Arg) Name

func (a Level2Arg) Name(name string) Arg

func (Level2Arg) Option

func (a Level2Arg) Option() Arg

func (Level2Arg) Validate

func (Level2Arg) Validate(idx int, src string) error

type Level3

type Level3 struct {
	V [3]string
}

func (Level3) DicePathAble

func (Level3) DicePathAble()

type Level3Arg

type Level3Arg struct {
	CommonArg
}

func (Level3Arg) Convert

func (Level3Arg) Convert(src string) interface{}

func (Level3Arg) ConvertType

func (Level3Arg) ConvertType() string

func (Level3Arg) Name

func (a Level3Arg) Name(name string) Arg

func (Level3Arg) Option

func (a Level3Arg) Option() Arg

func (Level3Arg) Validate

func (Level3Arg) Validate(idx int, src string) error

type Level4

type Level4 struct {
	V [4]string
}

func (Level4) DicePathAble

func (Level4) DicePathAble()

type Level4Arg

type Level4Arg struct {
	CommonArg
}

func (Level4Arg) Convert

func (Level4Arg) Convert(src string) interface{}

func (Level4Arg) ConvertType

func (Level4Arg) ConvertType() string

func (Level4Arg) Name

func (a Level4Arg) Name(name string) Arg

func (Level4Arg) Option

func (a Level4Arg) Option() Arg

func (Level4Arg) Validate

func (Level4Arg) Validate(idx int, src string) error

type Level5

type Level5 struct {
	V [5]string
}

func (Level5) DicePathAble

func (Level5) DicePathAble()

type Level5Arg

type Level5Arg struct {
	CommonArg
}

func (Level5Arg) Convert

func (Level5Arg) Convert(src string) interface{}

func (Level5Arg) ConvertType

func (Level5Arg) ConvertType() string

func (Level5Arg) Name

func (a Level5Arg) Name(name string) Arg

func (Level5Arg) Option

func (a Level5Arg) Option() Arg

func (Level5Arg) Validate

func (Level5Arg) Validate(idx int, src string) error

type Level6

type Level6 struct {
	V [6]string
}

type Level6Arg

type Level6Arg struct {
	CommonArg
}

func (Level6Arg) Convert

func (Level6Arg) Convert(src string) interface{}

func (Level6Arg) ConvertType

func (Level6Arg) ConvertType() string

func (Level6Arg) Name

func (a Level6Arg) Name(name string) Arg

func (Level6Arg) Option

func (a Level6Arg) Option() Arg

func (Level6Arg) Validate

func (Level6Arg) Validate(idx int, src string) error

type MetadataResponse

type MetadataResponse struct {
	OpenapiPublicUrl string                  `json:"openapi_public_url,omitempty"`
	Version          MetadataResponseVersion `json:"version,omitempty"`
}

type MetadataResponseVersion

type MetadataResponseVersion struct {
	Built       string `json:"built"`
	DiceVersion string `json:"dice_version"`
	GitCommit   string `json:"git_commit"`
	GoVersion   string `json:"go_version"`
}

type OrgInfo

type OrgInfo struct {
	ID   uint64 `json:"id"`
	Name string `json:"name"`
	Desc string `json:"desc"`
}

type OrgsResponseData

type OrgsResponseData struct {
	List  []OrgInfo `json:"list"`
	Total int       `json:"total"`
}

type ProjectInfo

type ProjectInfo struct {
	Version      string            `yaml:"version"`
	Server       string            `yaml:"server"`
	Org          string            `yaml:"org"`
	OrgID        uint64            `yaml:"org_id"`
	Project      string            `yaml:"project"`
	ProjectID    uint64            `yaml:"project_id"`
	Applications []ApplicationInfo `yaml:"applications"`
}

func GetProjectConfig

func GetProjectConfig() (string, *ProjectInfo, error)

func GetProjectConfigFrom

func GetProjectConfigFrom(configfile string) (*ProjectInfo, error)

type StringArg

type StringArg struct {
	CommonArg
}

func (StringArg) Convert

func (StringArg) Convert(src string) interface{}

func (StringArg) ConvertType

func (StringArg) ConvertType() string

func (StringArg) Name

func (a StringArg) Name(name string) Arg

func (StringArg) Option

func (a StringArg) Option() Arg

func (StringArg) Validate

func (StringArg) Validate(idx int, src string) error

type StringFlag

type StringFlag struct {
	Short        string
	Name         string
	Doc          string
	DefaultValue string
}

func (StringFlag) DefaultV

func (v StringFlag) DefaultV() string

func (StringFlag) Flag

func (StringFlag) Flag()

type StringListFlag

type StringListFlag struct {
	Short        string
	Name         string
	Doc          string
	DefaultValue []string
}

func (StringListFlag) DefaultV

func (v StringListFlag) DefaultV() string

[]string{`a`, `b`}

func (StringListFlag) Flag

func (StringListFlag) Flag()

type Uint64Flag

type Uint64Flag struct {
	Short        string
	Name         string
	Doc          string
	DefaultValue uint64
}

func (Uint64Flag) DefaultV

func (v Uint64Flag) DefaultV() string

func (Uint64Flag) Flag

func (Uint64Flag) Flag()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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