captain

package
v0.0.0-...-7426b64 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: BSD-3-Clause Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableMousetrap

func DisableMousetrap()

Types

type ArgMarshaler

type ArgMarshaler interface {
	Set(string) error
}

type Argument

type Argument struct {
	Name        string
	Description string
	Required    bool
	Value       interface{}
}

Argument is used to define flags in our Command struct

type Command

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

func NewCommand

func NewCommand(name, title, description string, prime primer, flags []*Flag, args []*Argument, execute ExecuteFunc) *Command

func NewHiddenShimCommand

func NewHiddenShimCommand(name string, prime primer, flags []*Flag, args []*Argument, execute ExecuteFunc) *Command

NewHiddenShimCommand is a very specialized function that is used for adding the PPM Shim. Differences to NewCommand() are: - the entrypoint is hidden in the help text - calling the help for a subcommand will execute this subcommand

func NewShimCommand

func NewShimCommand(name, description string, execute ExecuteFunc) *Command

NewShimCommand is a very specialized function that is used to support sub-commands for a hidden shim command. It has only a name a description and function to execute. All flags and arguments are ignored.

func (*Command) ActiveFlagNames

func (c *Command) ActiveFlagNames() []string

func (*Command) ActiveFlags

func (c *Command) ActiveFlags() []*Flag

func (*Command) AddChildren

func (c *Command) AddChildren(children ...*Command)

func (*Command) AddLegacyChildren

func (c *Command) AddLegacyChildren(children ...*cobra.Command)

func (*Command) Arguments

func (c *Command) Arguments() []*Argument

func (*Command) AvailableChildren

func (c *Command) AvailableChildren() []*Command

func (*Command) Children

func (c *Command) Children() []*Command

func (*Command) DeprioritizeInHelpListing

func (c *Command) DeprioritizeInHelpListing()

func (*Command) Description

func (c *Command) Description() string

func (*Command) Examples

func (c *Command) Examples() []string

func (*Command) Execute

func (c *Command) Execute(args []string) error

func (*Command) ExecuteFunc

func (c *Command) ExecuteFunc() ExecuteFunc

func (*Command) Find

func (c *Command) Find(args []string) (*Command, error)

func (*Command) Flags

func (c *Command) Flags() []*Flag

func (*Command) GenBashCompletions

func (c *Command) GenBashCompletions() (string, error)

func (*Command) GenFishCompletions

func (c *Command) GenFishCompletions() (string, error)

func (*Command) GenPowerShellCompletion

func (c *Command) GenPowerShellCompletion() (string, error)

func (*Command) GenZshCompletion

func (c *Command) GenZshCompletion() (string, error)

func (*Command) Group

func (c *Command) Group() CommandGroup

func (*Command) Help

func (c *Command) Help() string

func (*Command) Hidden

func (c *Command) Hidden() bool

func (*Command) InheritedFlagUsages

func (c *Command) InheritedFlagUsages() string

InheritedFlagUsages is a substitute for c.cobra.InheritedFlags().FlagUsages() to replace Cobra's intuited flag value placeholders with "<value>".

func (*Command) JoinedCommandNames

func (c *Command) JoinedCommandNames() string

func (*Command) JoinedSubCommandNames

func (c *Command) JoinedSubCommandNames() string

func (*Command) LocalFlagUsages

func (c *Command) LocalFlagUsages() string

LocalFlagUsages is a substitute for c.cobra.LocalFlags().FlagUsages() to replace Cobra's intuited flag value placeholders with "<value>".

func (*Command) Name

func (c *Command) Name() string

func (*Command) NamePadding

func (c *Command) NamePadding() int

func (*Command) NameRecursive

func (c *Command) NameRecursive() string

func (*Command) OnExecStart

func (c *Command) OnExecStart(handler ExecEventHandler)

func (*Command) OnExecStop

func (c *Command) OnExecStop(handler ExecEventHandler)

func (*Command) Parent

func (c *Command) Parent() *Command

func (*Command) SetAliases

func (c *Command) SetAliases(aliases ...string)

func (*Command) SetDeferAnalytics

func (c *Command) SetDeferAnalytics(value bool)

func (*Command) SetDescription

func (c *Command) SetDescription(description string)

func (*Command) SetDisableFlagParsing

func (c *Command) SetDisableFlagParsing(b bool)

func (*Command) SetExamples

func (c *Command) SetExamples(examples ...string) *Command

func (*Command) SetGroup

func (c *Command) SetGroup(group CommandGroup) *Command

SetGroup sets the group this command belongs to. This defaults to empty, meaning the command is ungrouped. Realistically only top level commands really need a group.

func (*Command) SetHasVariableArguments

func (c *Command) SetHasVariableArguments() *Command

SetHasVariableArguments allows a captain Command to accept a variable number of command line arguments. By default, captain has Cobra restrict the command line arguments accepted to those given in the []*Argument list to NewCommand().

func (*Command) SetHidden

func (c *Command) SetHidden(value bool)

func (*Command) SetSkipChecks

func (c *Command) SetSkipChecks(value bool)

func (*Command) SetSupportsStructuredOutput

func (c *Command) SetSupportsStructuredOutput() *Command

func (*Command) SetUnstable

func (c *Command) SetUnstable(unstable bool) *Command

SetUnstable denotes if the command as a beta feature. This will remove the command from state help, disable the commmand for those who haven't opted in to beta features, and add a warning banner for those who have.

func (*Command) ShortDescription

func (c *Command) ShortDescription() string

func (*Command) SkipChecks

func (c *Command) SkipChecks() bool

func (*Command) SortBefore

func (c *Command) SortBefore(c2 *Command) bool

func (*Command) Title

func (c *Command) Title() string

func (*Command) TopParent

func (c *Command) TopParent() *Command

func (*Command) Unstable

func (c *Command) Unstable() bool

func (*Command) Usage

func (cmd *Command) Usage() error

func (*Command) UsageText

func (c *Command) UsageText() string

func (*Command) Use

func (c *Command) Use() string

type CommandGroup

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

func NewCommandGroup

func NewCommandGroup(name string, priority int) CommandGroup

func (CommandGroup) SortBefore

func (c CommandGroup) SortBefore(c2 CommandGroup) bool

func (CommandGroup) String

func (c CommandGroup) String() string

type ExecEventHandler

type ExecEventHandler func(cmd *Command, args []string) error

type ExecuteFunc

type ExecuteFunc func(cmd *Command, args []string) error

type Flag

type Flag struct {
	Name        string
	Shorthand   string
	Description string
	Persist     bool
	Value       interface{}
	Hidden      bool

	OnUse func()
}

Flag is used to define flags in our Command struct

type FlagMarshaler

type FlagMarshaler pflag.Value

type IntValue

type IntValue struct {
	Int *int
	// contains filtered or unexported fields
}

func (*IntValue) IsSet

func (i *IntValue) IsSet() bool

func (*IntValue) Set

func (i *IntValue) Set(v string) error

func (*IntValue) String

func (i *IntValue) String() string

func (*IntValue) Type

func (i *IntValue) Type() string

type NameVersionValue

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

NameVersionValue represents a flag that supports both a name and a version, the following formats are supported: - name - name@version

func (*NameVersionValue) Name

func (nv *NameVersionValue) Name() string

func (*NameVersionValue) Set

func (nv *NameVersionValue) Set(arg string) error

func (*NameVersionValue) String

func (nv *NameVersionValue) String() string

func (*NameVersionValue) Type

func (nv *NameVersionValue) Type() string

func (*NameVersionValue) Version

func (nv *NameVersionValue) Version() string

type NullBool

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

func (*NullBool) AsPtrTo

func (b *NullBool) AsPtrTo() *bool

func (*NullBool) IsSet

func (b *NullBool) IsSet() bool

func (*NullBool) Set

func (b *NullBool) Set(v string) error

func (*NullBool) String

func (b *NullBool) String() string

func (*NullBool) Type

func (b *NullBool) Type() string

type NullInt

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

func (*NullInt) AsPtrTo

func (n *NullInt) AsPtrTo() *int

func (*NullInt) IsSet

func (n *NullInt) IsSet() bool

func (*NullInt) Set

func (n *NullInt) Set(v string) error

func (*NullInt) String

func (n *NullInt) String() string

func (*NullInt) Type

func (n *NullInt) Type() string

type NullString

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

func (*NullString) AsPtrTo

func (s *NullString) AsPtrTo() *string

func (*NullString) IsSet

func (s *NullString) IsSet() bool

func (*NullString) Set

func (s *NullString) Set(v string) error

func (*NullString) String

func (s *NullString) String() string

func (*NullString) Type

func (s *NullString) Type() string

type PackageValue

type PackageValue struct {
	Namespace string
	Name      string
	Version   string
}

PackageValue represents a flag that supports specifying a package in the following formats: - <name> - <namespace>:<name> - <namespace>:<name>@<version>

func (*PackageValue) Set

func (p *PackageValue) Set(s string) error

func (*PackageValue) String

func (p *PackageValue) String() string

func (*PackageValue) Type

func (p *PackageValue) Type() string

type PackageValueNSRequired

type PackageValueNSRequired struct {
	PackageValue
}

PackageValueNSRequired is identical to PackageValue except that specifying a namespace is required.

func (*PackageValueNSRequired) Set

func (*PackageValueNSRequired) Type

func (p *PackageValueNSRequired) Type() string

type PackageValueNoVersion

type PackageValueNoVersion struct {
	PackageValue
}

PackageValueNoVersion is identical to PackageValue except that it does not support a version.

func (*PackageValueNoVersion) Set

func (*PackageValueNoVersion) Type

func (p *PackageValueNoVersion) Type() string

type PackagesValue

type PackagesValue []PackageValue

PackagesValue is used to represent multiple PackageValue, this is used when a flag can be passed multiple times.

func (*PackagesValue) Set

func (p *PackagesValue) Set(s string) error

func (*PackagesValue) String

func (p *PackagesValue) String() string

func (*PackagesValue) Type

func (p *PackagesValue) Type() string

type PackagesValueNoVersion

type PackagesValueNoVersion []PackageValueNoVersion

func (*PackagesValueNoVersion) Set

func (*PackagesValueNoVersion) String

func (p *PackagesValueNoVersion) String() string

func (*PackagesValueNoVersion) Type

func (p *PackagesValueNoVersion) Type() string

type TimeValue

type TimeValue struct {
	Time *time.Time
	// contains filtered or unexported fields
}

func (*TimeValue) Now

func (u *TimeValue) Now() bool

func (*TimeValue) Set

func (u *TimeValue) Set(v string) error

func (*TimeValue) String

func (u *TimeValue) String() string

func (*TimeValue) Type

func (u *TimeValue) Type() string

type UserValue

type UserValue struct {
	Name  string
	Email string
}

UserValue represents a flag that supports both a name and an email address, the following formats are supported: - name <email> - email Emails are detected simply by containing a @ symbol.

func (*UserValue) Set

func (u *UserValue) Set(s string) error

func (*UserValue) String

func (u *UserValue) String() string

func (*UserValue) Type

func (u *UserValue) Type() string

type UsersValue

type UsersValue []UserValue

UsersValue is used to represent multiple UserValue, this is used when a flag can be passed multiple times.

func (*UsersValue) Set

func (u *UsersValue) Set(s string) error

func (*UsersValue) String

func (u *UsersValue) String() string

func (*UsersValue) Type

func (u *UsersValue) Type() string

Jump to

Keyboard shortcuts

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