Documentation
¶
Overview ¶
Package cmd provides CLI flag registration using a modular pattern.
To add a new flag without causing merge conflicts: 1. Create a new file (e.g., flags_myfeature.go) 2. Define your flag variable and default at the top 3. Create an init() function that calls RegisterFlag()
Example (flags_myfeature.go):
package cmd
var myFeatureEnabled bool
func init() {
RegisterFlag(func(cmd *cobra.Command) {
cmd.Flags().BoolVar(&myFeatureEnabled, "my-feature", false, "Enable my feature")
})
}
Index ¶
Constants ¶
View Source
const ( // DefaultListenIPv4 is the default interface used by the HTTP server. DefaultListenIPv4 = "127.0.0.1" // DefaultListenPort is the default port used by the HTTP server. DefaultListenPort = "3000" )
Exported constants for use by other packages
Variables ¶
This section is empty.
Functions ¶
func RegisterFlag ¶
func RegisterFlag(fn FlagRegistrar)
RegisterFlag adds a flag registrar to be called during init This allows each feature to register its own flags without modifying root.go
Types ¶
type FlagRegistrar ¶
FlagRegistrar is a function that registers flags on a command
Click to show internal directories.
Click to hide internal directories.