cmd

package
v0.0.0-...-9750751 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintUsage

func PrintUsage()

func PrintVersionOrUsage

func PrintVersionOrUsage()

func Register

func Register(c ICommand) bool

func Write

func Write(w io.Writer)

func WriteCommand

func WriteCommand(w io.Writer)

Types

type Command

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

func (*Command) AddDetails

func (c *Command) AddDetails(txt string)

func (*Command) AddExample

func (c *Command) AddExample(cmdExample string, desc string)

func (*Command) GetDesc

func (c *Command) GetDesc() string

func (*Command) GetDetails

func (c *Command) GetDetails() string

func (*Command) GetExample

func (c *Command) GetExample() string

func (*Command) GetName

func (c *Command) GetName() string

func (*Command) GetSynopsis

func (c *Command) GetSynopsis() string

func (*Command) Init

func (c *Command) Init(name string, desc string)

func (*Command) Parse

func (c *Command) Parse(arguments []string) (err error)

func (*Command) PrintUsage

func (c *Command) PrintUsage()

func (*Command) SetSynopsis

func (c *Command) SetSynopsis(str string)

func (*Command) Validate

func (c *Command) Validate()

func (*Command) Write

func (c *Command) Write(w io.Writer)

type Group

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

func RegisterNewGroup

func RegisterNewGroup(name string, cmds ...ICommand) (grp *Group)

type ICommand

type ICommand interface {
	GetName() string
	GetDesc() string //get short description
	GetSynopsis() string
	GetDetails() string
	GetOptionDesc() string
	GetExample() string
	AddExample(cmdExample string, desc string)
	AddDetails(txt string)
	Init(name string, desc string)
	Exec()
	Parse(args []string) error
	PrintUsage()
}

func GetCommand

func GetCommand(name string) ICommand

func ParseCommandLine

func ParseCommandLine() (cmd ICommand, args []string)

type Option

type Option struct {
	flag.FlagSet
	// contains filtered or unexported fields
}

func (*Option) BoolOption

func (o *Option) BoolOption(p *bool, name string, value bool, usage string)

func (*Option) GetOptionDesc

func (o *Option) GetOptionDesc() string

func (*Option) IntOption

func (o *Option) IntOption(p *int, name string, value int, usage string)

func (*Option) StringOption

func (o *Option) StringOption(p *string, name string, value string, usage string)

func (*Option) UintOption

func (o *Option) UintOption(p *uint, name string, value uint, usage string)

func (*Option) ValueOption

func (o *Option) ValueOption(value flag.Value, name string, usage string)

Jump to

Keyboard shortcuts

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