app

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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
}

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) GetRootCmd

func (a *App) GetRootCmd() *cobra.Command

func (*App) Run

func (a *App) Run()

Run is used to launch the application.

type ConfigurableOptions

type ConfigurableOptions interface {
	// ApplyFlags parsing parameters from the command line or configuration file
	// to the options instance.
	ApplyFlags() []error
}

ConfigurableOptions abstracts configuration options for reading parameters from a configuration file.

type Option

type Option func(*App)

Option defines optional parameters for initializing the application structure.

func WithDescription

func WithDescription(desc string) Option

WithDescription is used to set the description of the application.

func WithOptions

func WithOptions(opt Options) 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

func WithSilence

func WithSilence() Option

WithSilence sets the application to silent mode, in which the program startup information, configuration information, and version information are not printed in the console.

type Options

type Options interface {
	// AddFlags adds flags to the specified FlagSet object.
	AddFlags(fs *pflag.FlagSet)
}

Options abstracts configuration options for reading parameters from the command line.

type RunFunc

type RunFunc func(basename string) error

RunFunc defines the application's startup callback function.

type ServerOptions

type ServerOptions interface {
	ApplyToServer(server *server.Server) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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