cli

package
v0.0.487 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHelp = util.NewReadableError(nil, "")

Functions

This section is empty.

Types

type Argument

type Argument struct {
	Name        string      `json:"name"`
	Required    bool        `json:"required"`
	Description Description `json:"description"`
}

type ArgumentList

type ArgumentList []Argument

func (ArgumentList) String

func (a ArgumentList) String() string

type Cli

type Cli struct {
	Context context.Context
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, cancel context.CancelFunc, root *Command, version string) (*Cli, error)

func (*Cli) Arguments

func (c *Cli) Arguments() []string

func (*Cli) Bool

func (c *Cli) Bool(name string) bool

func (*Cli) Cancel

func (c *Cli) Cancel()

func (*Cli) InitProject

func (c *Cli) InitProject() (*project.Project, error)

func (*Cli) Path

func (c *Cli) Path() CommandPath

func (*Cli) Positional

func (c *Cli) Positional(index int) string

func (*Cli) PrintHelp

func (c *Cli) PrintHelp() error

func (*Cli) Run

func (c *Cli) Run() error

func (*Cli) Stage

func (c *Cli) Stage(cfgPath string) (string, error)

func (*Cli) String

func (c *Cli) String(name string) string

type Command

type Command struct {
	Name        string               `json:"name"`
	Hidden      bool                 `json:"hidden"`
	Description Description          `json:"description"`
	Args        ArgumentList         `json:"args"`
	Flags       []Flag               `json:"flags"`
	Examples    []Example            `json:"examples"`
	Children    []*Command           `json:"children"`
	Run         func(cli *Cli) error `json:"-"`
}

type CommandPath

type CommandPath []Command

func (CommandPath) PrintHelp

func (c CommandPath) PrintHelp() error

type Description

type Description struct {
	Short string `json:"short,omitempty"`
	Long  string `json:"long,omitempty"`
}

type Example

type Example struct {
	Content     string      `json:"content"`
	Description Description `json:"description"`
}

type Flag

type Flag struct {
	Name        string      `json:"name"`
	Type        string      `json:"type"`
	Description Description `json:"description"`
}

Jump to

Keyboard shortcuts

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