clir: github.com/leaanthony/clir Index | Files

package clir

import "github.com/leaanthony/clir"

Package clir provides a simple API for creating command line apps

Index

Package Files

action.go cli.go clir.go command.go

type Action Uses

type Action func() error

Action represents a function that gets calls when the command is called by the user

type Cli Uses

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

Cli - The main application object

func NewCli Uses

func NewCli(name, description, version string) *Cli

NewCli - Creates a new Cli application object

func (*Cli) Abort Uses

func (c *Cli) Abort(err error)

Abort prints the given error and terminates the application

func (*Cli) Action Uses

func (c *Cli) Action(callback Action) *Cli

Action - Define an action from this command

func (*Cli) AddCommand Uses

func (c *Cli) AddCommand(command *Command)

AddCommand - Adds a command to the application

func (*Cli) BoolFlag Uses

func (c *Cli) BoolFlag(name, description string, variable *bool) *Cli

BoolFlag - Adds a boolean flag to the root command

func (*Cli) DefaultCommand Uses

func (c *Cli) DefaultCommand(defaultCommand *Command) *Cli

DefaultCommand - Sets the given command as the command to run when no other commands given

func (*Cli) IntFlag Uses

func (c *Cli) IntFlag(name, description string, variable *int) *Cli

IntFlag - Adds an int flag to the root command

func (*Cli) LongDescription Uses

func (c *Cli) LongDescription(longdescription string) *Cli

LongDescription - Sets the long description for the command

func (*Cli) Name Uses

func (c *Cli) Name() string

Name - Get the Application Name

func (*Cli) NewSubCommand Uses

func (c *Cli) NewSubCommand(name, description string) *Command

NewSubCommand - Creates a new SubCommand for the application

func (*Cli) OtherArgs Uses

func (c *Cli) OtherArgs() []string

OtherArgs - Returns the non-flag arguments passed to the cli. NOTE: This should only be called within the context of an action.

func (*Cli) PreRun Uses

func (c *Cli) PreRun(callback func(*Cli) error)

PreRun - Calls the given function before running the specific command

func (*Cli) PrintBanner Uses

func (c *Cli) PrintBanner()

PrintBanner prints the application banner!

func (*Cli) PrintHelp Uses

func (c *Cli) PrintHelp()

PrintHelp - Prints the application's help

func (*Cli) Run Uses

func (c *Cli) Run(args ...string) error

Run - Runs the application with the given arguments

func (*Cli) SetBannerFunction Uses

func (c *Cli) SetBannerFunction(fn func(*Cli) string)

SetBannerFunction is used to set the function that is called to get the banner string.

func (*Cli) ShortDescription Uses

func (c *Cli) ShortDescription() string

ShortDescription - Get the Application short description

func (*Cli) StringFlag Uses

func (c *Cli) StringFlag(name, description string, variable *string) *Cli

StringFlag - Adds a string flag to the root command

func (*Cli) Version Uses

func (c *Cli) Version() string

Version - Get the Application version string

type Command Uses

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

Command represents a command that may be run by the user

func NewCommand Uses

func NewCommand(name string, description string) *Command

NewCommand creates a new Command func NewCommand(name string, description string, app *Cli, parentCommandPath string) *Command {

func (*Command) Action Uses

func (c *Command) Action(callback Action) *Command

Action - Define an action from this command

func (*Command) AddCommand Uses

func (c *Command) AddCommand(command *Command)

AddCommand - Adds a subcommand

func (*Command) BoolFlag Uses

func (c *Command) BoolFlag(name, description string, variable *bool) *Command

BoolFlag - Adds a boolean flag to the command

func (*Command) Hidden Uses

func (c *Command) Hidden()

Hidden hides the command from the Help system

func (*Command) IntFlag Uses

func (c *Command) IntFlag(name, description string, variable *int) *Command

IntFlag - Adds an int flag to the command

func (*Command) LongDescription Uses

func (c *Command) LongDescription(longdescription string) *Command

LongDescription - Sets the long description for the command

func (*Command) NewSubCommand Uses

func (c *Command) NewSubCommand(name, description string) *Command

NewSubCommand - Creates a new subcommand

func (*Command) OtherArgs Uses

func (c *Command) OtherArgs() []string

OtherArgs - Returns the non-flag arguments passed to the subcommand. NOTE: This should only be called within the context of an action.

func (*Command) PrintHelp Uses

func (c *Command) PrintHelp()

PrintHelp - Output the help text for this command

func (*Command) StringFlag Uses

func (c *Command) StringFlag(name, description string, variable *string) *Command

StringFlag - Adds a string flag to the command

Package clir imports 5 packages (graph) and is imported by 1 packages. Updated 2020-05-17. Refresh now. Tools for package owners.