Documentation
¶
Overview ¶
Package clippy handles registering CLI flags via a plug-in mechanism. Additionally, optional CLI flag handling can be carried out after the CLI flags have been parsed and just right before the selected command is about to run.
Packages providing CLI flags need to register themselves using the go-plugger mechanism providing functions assignable to cliplugin.SetupCLI. This makes it possible to register multiple flags from the same package in a highly modular fashion just by specifying individual plug-in functions, for instance, per each individual flag.
Registering cliplugin.BeforeCommand functions allows for modular processing of flags before the (root) command is run.
Registration of the exported functions should be done in init functions. For better modularity, multiple registration-related init functions can perfectly co-exist within the same package. You might want to specify different “plug-in names” upon function registration.
It already sufficies when a cmd package references a CLI-related package to pull in its CLI flag registrations. A cmd package then should make sure to call AddFlags and BeforeCommand respectively.
AddFlags should be called after your cmd package has created the root command object and is ready for registering flags.
BeforeCommand should be called from the PersistentPreRunE hook function of your cmd package's root command object.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFlags ¶
AddFlags runs all registered cliplugin.SetupCLI plugin functions in order to register CLI flags for the specified root command.
func BeforeCommand ¶
BeforeCommand runs all registered cliplugin.BeforeCommand plugin functions just before the selected command runs; it terminates as soon as the first plugin function returns a non-nil error.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package debug supplies the “--debug” and “--tinted” CLI flags for configuring the default structured logger.
|
Package debug supplies the “--debug” and “--tinted” CLI flags for configuring the default structured logger. |
|
Package log supplies the "--log" CLI flag and automatically implies "--debug" and "--tinted" CLI flags for configuring the default structured logger.
|
Package log supplies the "--log" CLI flag and automatically implies "--debug" and "--tinted" CLI flags for configuring the default structured logger. |
|
Package work provides running plugin work functions in parallel, such as for continuously servicing HTTP endpoints, running continuous background work, and more.
|
Package work provides running plugin work functions in parallel, such as for continuously servicing HTTP endpoints, running continuous background work, and more. |