Documentation ¶
Index ¶
- func AddConfigFlag(fs *pflag.FlagSet, name string, watch bool)
- func PrintConfig()
- type App
- type CliOptions
- type HealthCheckFunc
- type Option
- func WithDefaultHealthCheckFunc() Option
- func WithDefaultValidArgs() Option
- func WithDescription(desc string) Option
- func WithHealthCheckFunc(fn HealthCheckFunc) Option
- func WithNoConfig() Option
- func WithOptions(opts CliOptions) Option
- func WithRunFunc(run RunFunc) Option
- func WithSilence() Option
- func WithValidArgs(args cobra.PositionalArgs) Option
- func WithWatchConfig() Option
- type RunFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddConfigFlag ¶
AddConfigFlag adds flags for a specific server to the specified FlagSet object. It also sets a passed functions to read values from configuration file into viper when each cobra command's Execute method is called.
func PrintConfig ¶
func PrintConfig()
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the main structure of a cli application. It is recommended that an app be created with the app.NewApp() function.
func NewApp ¶
NewApp creates a new application instance based on the given application name, binary name, and other options.
type CliOptions ¶
type CliOptions interface { // Flags returns flags for a specific server by section name. Flags() cliflag.NamedFlagSets // Complete completes all the required options. Complete() error // Validate validates all the required options. Validate() error }
CliOptions abstracts configuration options for reading parameters from the command line.
type HealthCheckFunc ¶
type HealthCheckFunc func() error
HealthCheckFunc defines the health check function for the application.
type Option ¶
type Option func(*App)
Option defines optional parameters for initializing the application structure.
func WithDefaultHealthCheckFunc ¶
func WithDefaultHealthCheckFunc() Option
WithDefaultHealthCheckFunc set the default health check function.
func WithDefaultValidArgs ¶
func WithDefaultValidArgs() Option
WithDefaultValidArgs set default validation function to valid non-flag arguments.
func WithDescription ¶
WithDescription is used to set the description of the application.
func WithHealthCheckFunc ¶
func WithHealthCheckFunc(fn HealthCheckFunc) Option
WithHealthCheckFunc is used to set the health check function for the application. The app framework will use the function to start a health check server.
func WithNoConfig ¶
func WithNoConfig() Option
WithNoConfig set the application does not provide config flag.
func WithOptions ¶
func WithOptions(opts CliOptions) Option
WithOptions to open the application's function to read from the command line or read parameters from the configuration file.
func WithRunFunc ¶
WithRunFunc is used to set the application startup callback function 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.
func WithValidArgs ¶
func WithValidArgs(args cobra.PositionalArgs) Option
WithValidArgs set the validation function to valid non-flag arguments.
func WithWatchConfig ¶
func WithWatchConfig() Option
WithWatchConfig watching and re-reading config files.