cli_mate

package module
v0.0.0-...-aa394b1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2017 License: MIT Imports: 6 Imported by: 0

README

cli-mate

Build Status License

Base on urfave/cli

Installation

go get github.com/WindomZ/cli-mate

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	App    *cli.App
	Action CommandAction
	// contains filtered or unexported fields
}

App is the main structure of a cli application

func NewApp

func NewApp(name, usage, version string) *App

NewApp creates a new cli Application with Name, Usage and Version

func (*App) AddCommand

func (a *App) AddCommand(c Command) *App

AddCommand add a child Command to list of child Commands

func (*App) AddCommands

func (a *App) AddCommands(cs []Command) *App

AddCommands add an array of child Commands to list of child Commands

func (*App) AddFlag

func (a *App) AddFlag(f Flag) *App

AddFlag add a Flag to list of Flags

func (*App) AddFlags

func (a *App) AddFlags(fs []Flag) *App

AddFlags add an array of Flags to list of Flags

func (*App) Clear

func (a *App) Clear()

Clear clear Commands and Flags to the initial state

func (*App) Name

func (a *App) Name() string

func (*App) Run

func (a *App) Run(arguments []string) error

Run is the entry point to the cli app

func (*App) RunOSArgs

func (a *App) RunOSArgs() error

RunOSArgs same as Run with arguments from os

func (*App) Version

func (a *App) Version() string

type Command

type Command struct {
	Command cli.Command
	Action  CommandAction
	// contains filtered or unexported fields
}

Command is a subcommand for a cli.App

func (*Command) AddFlag

func (c *Command) AddFlag(f Flag)

AddFlag add a Flag to list of Flags

func (*Command) AddFlags

func (c *Command) AddFlags(fs []Flag)

AddFlags add an array of Flags to list of Flags

func (*Command) AddSubCommand

func (c *Command) AddSubCommand(cmd Command)

AddSubCommand add a child Command to list of child Commands

func (*Command) AddSubCommands

func (c *Command) AddSubCommands(cmds []Command)

AddSubCommands add an array of child Commands to list of child Commands

func (*Command) Clear

func (c *Command) Clear()

func (Command) Name

func (c Command) Name() string

Name returns the full name of the command

type CommandAction

type CommandAction func(c *Context) ExitCoder

CommandAction the function for Command action

type Context

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

func NewContext

func NewContext(c *cli.Context) *Context

func (*Context) Print

func (c *Context) Print(a ...interface{}) string

func (*Context) Println

func (c *Context) Println(a ...interface{}) string

func (*Context) ShowAppHelp

func (c *Context) ShowAppHelp() error

func (*Context) ShowCommandHelp

func (c *Context) ShowCommandHelp(command string) error

func (*Context) ShowSubcommandHelp

func (c *Context) ShowSubcommandHelp() error

func (*Context) Sprint

func (c *Context) Sprint(a ...interface{}) string

func (*Context) Sprintf

func (c *Context) Sprintf(format string, a ...interface{}) string

func (*Context) Sprintln

func (c *Context) Sprintln(a ...interface{}) string

type ExitCoder

type ExitCoder interface {
	cli.ExitCoder
	GetError() error
	IsBreak() bool
}

type ExitError

type ExitError struct {
	cli.ExitError
}
var BreakExit *ExitError = &ExitError{
	ExitError: *cli.NewExitError("break", 0),
}

BreakExit just for break action of command execute

func NewExitError

func NewExitError(err error, exitCode ...int) *ExitError

NewExitError makes a new *ExitError with error and code

func NewExitStringError

func NewExitStringError(err string, exitCodes ...int) *ExitError

NewExitStringError makes a new *ExitError with string and code

func (ExitError) GetError

func (e ExitError) GetError() error

func (ExitError) IsBreak

func (e ExitError) IsBreak() bool

type Flag

type Flag struct {
	Flag     cli.Flag
	FlagName string
	Action   FlagAction
}

Flag is a common interface related to parsing flags in cli.

func (*Flag) Apply

func (f *Flag) Apply(set *flag.FlagSet)

Apply Flag settings to the given flag set

func (Flag) GetName

func (f Flag) GetName() string

GetName get the name of Flag

func (Flag) Name

func (f Flag) Name() string

Name same as GetName

type FlagAction

type FlagAction func(c *Context, f *Flag) ExitCoder

FlagAction the function for Flag action

Jump to

Keyboard shortcuts

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