components

package
v2.52.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 9 Imported by: 59

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertApp

func ConvertApp(jfrogApp App) (*cli.App, error)

func ConvertAppCommands added in v2.47.11

func ConvertAppCommands(jfrogApp App, commandPrefix ...string) (cmds []cli.Command, err error)

Types

type ActionFunc

type ActionFunc func(c *Context) error

type App

type App struct {
	Version string
	Namespace
	Subcommands []Namespace
}

func CreateApp added in v2.47.10

func CreateApp(name, version, description string, commands []Command) App

func CreateEmbeddedApp added in v2.47.11

func CreateEmbeddedApp(name string, commands []Command, namespaces ...Namespace) App

type Argument

type Argument struct {
	Name string
	// Is this argument optional? If so, the 'Optional' field should be set to true.
	// This field is used for creating help usages, for instance if argument is:
	// Argument {
	// 		Name: "optional-arg",
	// 		Optional: true,
	// }
	// The help usage that will be created will be:
	//
	// Usage:
	// 	1) cmd-name [cmd options] [optional-arg]
	//
	// Else, if the argument is mandatory ( Argument { Name: "mandatory-arg" } ), the help usage will be:
	//
	// Usage:
	// 	1) cmd-name [cmd options] <mandatory-arg>
	Optional bool
	// Is this argument optional and can be replaced with a flag?
	// If so, the 'Optional' field should be set to true and the 'ReplaceWithFlag' field should be set to the flag name.
	// This field is used for creating help usages, for instance if argument is:
	// Argument {
	// 		Name: "optional-arg",
	// 		Optional: true,
	// 		ReplaceWithFlag: "flag-replacement",
	// }
	// The help usage that will be created will be:
	//
	// Usage:
	// 	1) cmd-name [cmd options] [optional-arg]
	// 	2) cmd-name [cmd options] --flag-replacement=value
	ReplaceWithFlag string
	Description     string
}

type BaseFlag added in v2.47.10

type BaseFlag struct {
	Name        string
	Description string
	Hidden      bool
}

func NewFlag added in v2.47.10

func NewFlag(name, description string) BaseFlag

func (BaseFlag) GetDescription added in v2.47.10

func (f BaseFlag) GetDescription() string

func (BaseFlag) GetName added in v2.47.10

func (f BaseFlag) GetName() string

func (BaseFlag) IsMandatory added in v2.47.10

func (f BaseFlag) IsMandatory() bool

type BoolFlag

type BoolFlag struct {
	BaseFlag
	DefaultValue bool
}

func NewBoolFlag added in v2.47.10

func NewBoolFlag(name, description string, options ...BoolFlagOption) BoolFlag

func (BoolFlag) GetDefault

func (f BoolFlag) GetDefault() bool

type BoolFlagOption added in v2.47.10

type BoolFlagOption func(f *BoolFlag)

func SetHiddenBoolFlag added in v2.47.10

func SetHiddenBoolFlag() BoolFlagOption

func WithBoolDefaultValue added in v2.47.10

func WithBoolDefaultValue(defaultValue bool) BoolFlagOption

type Command

type Command struct {
	Name            string
	Description     string
	Category        string
	Aliases         []string
	UsageOptions    *UsageOptions
	Arguments       []Argument
	Flags           []Flag
	EnvVars         []EnvVar
	Action          ActionFunc
	SkipFlagParsing bool
	Hidden          bool
}

type Context

type Context struct {
	Arguments   []string
	CommandName string

	PrintCommandHelp func(commandName string) error
	// contains filtered or unexported fields
}

func ConvertContext added in v2.47.11

func ConvertContext(baseContext *cli.Context, flagsToConvert ...Flag) (*Context, error)

func (*Context) GetBoolFlagValue

func (c *Context) GetBoolFlagValue(flagName string) bool

func (*Context) GetIntFlagValue added in v2.47.10

func (c *Context) GetIntFlagValue(flagName string) (value int, err error)

func (*Context) GetStringFlagValue

func (c *Context) GetStringFlagValue(flagName string) string

func (*Context) IsFlagSet added in v2.47.10

func (c *Context) IsFlagSet(flagName string) bool

type EnvVar

type EnvVar struct {
	Name        string
	Default     string
	Description string
}

type Flag

type Flag interface {
	GetName() string
	IsMandatory() bool
	GetDescription() string
}

type Namespace added in v2.47.10

type Namespace struct {
	Name        string
	Description string
	Category    string
	Commands    []Command
}

type PluginSignature

type PluginSignature struct {
	Name  string `json:"name,omitempty"`
	Usage string `json:"usage,omitempty"`
	// Only used internally in the CLI.
	ExecutablePath string `json:"executablePath,omitempty"`
}

type StringFlag

type StringFlag struct {
	BaseFlag
	Mandatory bool
	// A flag with default value cannot be mandatory.
	DefaultValue string
	// Optional. If provided, this field will be used for help usage. --<Name>=<HelpValue> else: --<Name>=<value>
	HelpValue string
}

func NewStringFlag added in v2.47.10

func NewStringFlag(name, description string, options ...StringFlagOption) StringFlag

func (StringFlag) GetDefault

func (f StringFlag) GetDefault() string

func (StringFlag) IsMandatory added in v2.47.10

func (f StringFlag) IsMandatory() bool

type StringFlagOption added in v2.47.10

type StringFlagOption func(f *StringFlag)

func SetHiddenStrFlag added in v2.47.10

func SetHiddenStrFlag() StringFlagOption

func SetMandatory added in v2.47.10

func SetMandatory() StringFlagOption

func WithHelpValue added in v2.47.10

func WithHelpValue(helpValue string) StringFlagOption

func WithIntDefaultValue added in v2.47.10

func WithIntDefaultValue(defaultValue int) StringFlagOption

func WithStrDefaultValue added in v2.47.10

func WithStrDefaultValue(defaultValue string) StringFlagOption

type UsageOptions added in v2.47.10

type UsageOptions struct {
	// Special cases, each of these will be created as command usage option and the value appended as suffix for the command name.
	Usage []string
	// If true then the given usages will replace the auto generated usage. Otherwise the given usages will be appended to the auto generated usage.
	ReplaceAutoGeneratedUsage bool
}

Jump to

Keyboard shortcuts

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