app

package
v0.0.0-...-523051e Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBaseName

func FormatBaseName(basename string) string

FormatBaseName is formatted as an executable file name under different operating systems according to the given name.

func WordSepNormalizeFunc

func WordSepNormalizeFunc(_ *pflag.FlagSet, name string) pflag.NormalizedName

WordSepNormalizeFunc changes all flags that contain "_" separators.

Types

type App

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

App is the main construct of a cli application. It is recommended that an app be created with the app.NewApp() function.

func NewApp

func NewApp(name string, basename string, opts ...Option) *App

NewApp creates a new application instance based on the given application name, binary name, and other options.

func (*App) Run

func (a *App) Run()

type CliOptions

type CliOptions interface {
	Flags() (fss cliflag.NamedFlagSets)
	Validate() []error
}

CliOptions abstracts configurations options for reading parameters from the command line.

type Command

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

Command is a sbu command structure of a cli application. It is recommended that a command be created with the app.NewCommand() function.

type Option

type Option func(*App)

Option defines optional parameters for initializing the application structure.

func WithDefaultValidArgs

func WithDefaultValidArgs() Option

WithDefaultValidArgs set default validation function to valid non-flag arguments.

func WithDescription

func WithDescription(desc string) Option

WithDescription is used to set the description of the application.

func WithOptions

func WithOptions(opt CliOptions) Option

WithOptions to open the application's function to read from the command line or read parameters from the configuration file.

func WithRunFunc

func WithRunFunc(run RunFunc) Option

WithRunFunc is used to set the application startup callback function option.

type RunCommandFunc

type RunCommandFunc func(args []string) error

RunCommandFunc defines the application's command startup callback function.

type RunFunc

type RunFunc func(basename string) error

RunFunc defines the application's startup callback function.

Jump to

Keyboard shortcuts

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