zcli

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BuildTime      = ""
	BuildGoVersion = ""
	// Log cli logger
	Log            *zlog.Logger
	FirstParameter = os.Args[0]

	// appConfig      = &App{
	// Lang: defaultLang,
	// }
	Description string
	Version     string
	HideHelp    bool
	HidePrompt  bool
	Lang        = defaultLang

	ShortValues = map[string]interface{}{}
)

Functions

func Add

func Add(name, description string, command Cmd) (cmd *cmdCont)

Add Registers a Cmd for the provided subCommand name

func Error

func Error(format string, v ...interface{})

func Help

func Help()

Help show help

func Parse added in v0.0.19

func Parse(arg ...[]string)

func Run

func Run(runFunc ...runFunc) (ok bool)

Run runnable

func SetUnknownCommand

func SetUnknownCommand(fn func(_ string))

func ShowFlags

func ShowFlags(fg *flag.FlagSet)

func ShowRequired

func ShowRequired(_ *flag.FlagSet, requiredFlags RequiredFlags)

func Start

func Start(runFunc ...runFunc)

Start Start

Types

type Cmd

type Cmd interface {
	Flags(subcommand *Subcommand)
	Run(args []string)
}

Cmd represents a subCommand

type RequiredFlags

type RequiredFlags []string

RequiredFlags RequiredFlags flags

type Subcommand

type Subcommand struct {
	CommandLine *flag.FlagSet
	Name        string
	Desc        string
	Supplement  string
	Parameter   string
	// contains filtered or unexported fields
}

type Var

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

func SetVar

func SetVar(name, usage string) *Var

func (*Var) Bool

func (v *Var) Bool(def ...bool) *bool

func (*Var) Int

func (v *Var) Int(def ...int) *int

func (*Var) Required

func (v *Var) Required() *Var

Required Set flag to be required

func (*Var) String

func (v *Var) String(def ...string) *string

Jump to

Keyboard shortcuts

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