cli

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package cli provides a easy way to organize a cli program. For advance usage, check https://pkg.go.dev/github.com/urfave/cli/v2. Check the example in ./example.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	cli.App

	SetupFunc CommandHandler
}

Apppplication is the main structure of a cli application.

var App Application

App is the default application.

func (*Application) Action

func (a *Application) Action(f CommandHandler)

Actions sets a handler running when no subcommands giving.

func (*Application) After

func (a *Application) After(f CommandHandler)

After hooks a handler to execute after any subcommands are run, but after the subcommand has finished. It is run even if Action() panics.

func (*Application) Before

func (a *Application) Before(f CommandHandler)

Before hooks a handler to execute before any sub-subcommands are run, but after the context is ready. If a non-nil error is returned, no sub-subcommands are run.

func (*Application) Command

func (a *Application) Command(name, usage string, f CommandHandler) *Command

Command adds a sub command to the application.

func (*Application) Setup added in v1.1.4

func (a *Application) Setup(f CommandHandler)

Setup hooks a handler to execute before any sub-subcommands are run, but after the context is ready. Help subcommand won't run this hook. If a non-nil error is returned, no sub-subcommands are run.

type Command

type Command struct {
	*cli.Command
}

func (*Command) Action

func (c *Command) Action(f CommandHandler)

func (*Command) After

func (c *Command) After(f CommandHandler)

func (*Command) Before

func (c *Command) Before(f CommandHandler)

type CommandHandler

type CommandHandler func(ctx *Context) error

CommandHandler is a function to handle something.

type Context

type Context struct {
	*cli.Context
}

func (*Context) SetFlag

func (c *Context) SetFlag(name, value string) error

func (*Context) StoreValue

func (c *Context) StoreValue(key string, value interface{})

func (*Context) Value

func (c *Context) Value(key interface{}) interface{}

type Flag

type Flag = cli.Flag

type FlagBool

type FlagBool = cli.BoolFlag

type FlagDuration

type FlagDuration = cli.DurationFlag

type FlagFloat64

type FlagFloat64 = cli.Float64Flag

type FlagFloat64Slice

type FlagFloat64Slice = cli.Float64SliceFlag

type FlagGeneric

type FlagGeneric = cli.GenericFlag

type FlagInt

type FlagInt = cli.IntFlag

type FlagInt64

type FlagInt64 = cli.Int64Flag

type FlagInt64Slice

type FlagInt64Slice = cli.Int64SliceFlag

type FlagIntSlice

type FlagIntSlice = cli.IntSliceFlag

type FlagPath

type FlagPath = cli.PathFlag

type FlagString

type FlagString = cli.StringFlag

type FlagStringSlice

type FlagStringSlice = cli.StringSliceFlag

type FlagTimestamp

type FlagTimestamp = cli.TimestampFlag

type FlagUint

type FlagUint = cli.UintFlag

type FlagUint64

type FlagUint64 = cli.Uint64Flag

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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