cli

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionFn added in v0.0.4

type ActionFn func(ctx context.Context, args []string) error

ActionFn represents the application's entry point function.

type App

type App struct {
	*cli.App
}

App is a wrapper of cli.App

func NewApp

func NewApp(name string) *App

NewApp create a new instance of the App struct

func (*App) AddCommands

func (app *App) AddCommands(commands ...*Command)

AddCommands adds subcommands

func (*App) AddFlags

func (app *App) AddFlags(flags ...*Flag)

AddFlags adds flags

func (*App) SetActionFunc

func (app *App) SetActionFunc(actionFn ActionFn)

SetActionFunc sets the Action function for the cli.App The action to execute when no subcommands are specified.

func (*App) SetBeforeFunc

func (app *App) SetBeforeFunc(beforeFn func() error)

SetBeforeFunc sets the Before fucntion for the cli.App An action to execute before any subcommands are run, but after the context is ready.

func (*App) SetError

func (app *App) SetError(write io.Writer)

SetError sets writer to write error output to.

func (*App) SetOutput

func (app *App) SetOutput(write io.Writer)

SetOutput sets writer to write output to.

func (*App) SetUsage

func (app *App) SetUsage(usage string)

SetUsage sets description of the program.

func (*App) SetVersion

func (app *App) SetVersion(version string)

SetVersion sets version of the program.

type Command

type Command struct {
	cli.Command
}

Command is a wrapper of cli.Command

func NewCommand

func NewCommand() *Command

NewCommand create a new instance of the Command struct

func (*Command) AddFlags

func (cmd *Command) AddFlags(flags ...*Flag)

AddFlags adds flags

func (*Command) AddSubcommands

func (cmd *Command) AddSubcommands(commands ...*Command)

AddSubcommands adds subcommands

func (*Command) SetActionFunc

func (cmd *Command) SetActionFunc(actionFn ActionFn)

SetActionFunc sets the Action fucntion for the cli.Command

func (*Command) SetBeforeFunc

func (cmd *Command) SetBeforeFunc(before func() error)

SetBeforeFunc sets the Before fucntion for the cli.Command

type Flag

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

Flag is a wrapper of cli.Flag

func NewFlag

func NewFlag(name string, destination interface{}) *Flag

NewFlag returns a new Flag instance. Where the `name` is a flag name and `destination` is a pointer to which the flag value will be assigned.

func (*Flag) SetAliases

func (s *Flag) SetAliases(val ...string) *Flag

SetAliases sets 'Aliases' field for the cli.Flag

func (*Flag) SetEnvVars

func (s *Flag) SetEnvVars(val ...string) *Flag

SetEnvVars sets 'EnvVars' field for the cli.Flag

func (*Flag) SetHidden

func (s *Flag) SetHidden() *Flag

SetHidden sets 'Hidden' field for the cli.Flag

func (*Flag) SetRequired

func (s *Flag) SetRequired() *Flag

SetRequired sets 'Required' field for the cli.Flag

func (*Flag) SetUsage

func (s *Flag) SetUsage(val string) *Flag

SetUsage sets 'Usage' field for the cli.Flag

func (*Flag) SetValue

func (s *Flag) SetValue(val interface{}) *Flag

SetValue sets 'Value' field for the cli.Flag

Jump to

Keyboard shortcuts

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