cli

package module
v0.0.0-...-2755b62 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2021 License: MIT Imports: 7 Imported by: 0

README

Command line interface framework for Go applications.

Documentation

Index

Constants

View Source
const (
	HelpOptionName      = "help"
	HelpOptionShortName = "h"
)
View Source
const (
	NoArguments = ""
)

Variables

This section is empty.

Functions

func Execute

func Execute(c *Command)

Types

type Command

type Command struct {
	Name        string
	Description string
	Author      string
	Version     string
	Subcommands []Subcommand
	Options     []Option
	// contains filtered or unexported fields
}

func (*Command) Validate

func (c *Command) Validate()

type Context

type Context struct {
	Output io.Writer
	// contains filtered or unexported fields
}

func (*Context) BoolOption

func (ctx *Context) BoolOption(name string) bool

func (*Context) IntOption

func (ctx *Context) IntOption(name string) int

func (*Context) StringOption

func (ctx *Context) StringOption(name string) (s string)

func (*Context) Subcommand

func (ctx *Context) Subcommand() string

type Example

type Example struct {
	Arguments   string
	Explanation string
}

type HandlerFunc

type HandlerFunc func(*Context)

type Option

type Option interface {
	Name() string
	ShortName() string
	Description() string
	Default() string
	Value() interface{}
	// contains filtered or unexported methods
}

func NewBoolOption

func NewBoolOption(name string, shortName string, description string) Option

func NewStringOption

func NewStringOption(name string, shortName string, description string, defaultValue string) Option

type Subcommand

type Subcommand struct {
	Name            string
	Description     string
	PosArgsUsage    string
	ValidOptions    []string
	RequiredOptions []string
	Examples        []Example
	Handler         HandlerFunc
}

func (*Subcommand) Requires

func (s *Subcommand) Requires(option string) bool

Jump to

Keyboard shortcuts

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