cmdos

package module
v0.0.0-...-09776fc Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HelpFlag = Flag{
	Short:       'h',
	Long:        "help",
	Description: "Print help.",
}

Functions

func DefaultValue

func DefaultValue(s string) defaultValue

func Run

func Run(root Command, args []string) error

func WriteHelp

func WriteHelp(w io.Writer, c Command) error

Types

type Command

type Command interface {
	Info() Info
	Flags() []Flag
	Run(vs *Values) error
}

type CommandSubcommands

type CommandSubcommands interface {
	Subcommands() []Command
}

type Flag

type Flag struct {
	Short rune
	Long  string

	Required    bool
	Variadic    bool
	Arg         *FlagArgument
	Description string
}

type FlagArgument

type FlagArgument struct {
	Name    string
	Default defaultValue
}

type Info

type Info struct {
	Name        string
	Description string
	ArgUsages   []string
}

type Values

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

func (*Values) Args

func (v *Values) Args() []string

func (*Values) DecodeValue

func (v *Values) DecodeValue(key string, dst any) error

func (*Values) Get

func (v *Values) Get(key string) string

func (*Values) GetAll

func (v *Values) GetAll(key string) []string

func (*Values) Has

func (v *Values) Has(key string) bool

Jump to

Keyboard shortcuts

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