Documentation
¶
Index ¶
Constants ¶
View Source
const ( // FlagName is the name of the mode flag. FlagName = "mode" // FlagUsage is the usage of the mode flag. It describes allowed values and the default mode. FlagUsage = "Specify mode. Allowed values are: %s. Default is the %s mode." )
Variables ¶
View Source
var ( // Dev is the development mode. Dev Mode = "dev" // Prod is the production mode. Prod Mode = "prod" // Debug is the debug mode. Debug Mode = "debug" // Migrate is the migration mode. Migrate Mode = "migrate" // Setup is the setup mode. Setup Mode = "setup" // DefaultMode is the default mode (development). DefaultMode = Dev // AllowedModes is the list of allowed modes. AllowedModes = []string{ string(Dev), string(Prod), string(Debug), string(Migrate), string(Setup), } // ModeFlag is the environment mode flag instance. ModeFlag = NewFlag( string(DefaultMode), nil, AllowedModes, FlagName, fmt.Sprintf( FlagUsage, strings.Join(AllowedModes, ", "), string(Dev), ), ) )
View Source
var (
ErrNilModeFlag = errors.New("mode flag cannot be nil")
)
Functions ¶
This section is empty.
Types ¶
type Flag ¶
Flag is a custom flag type for mode, embedding goflags.Flag.
func NewFlag ¶
func NewFlag( defaultValue string, value *string, allowed []string, name string, usage string, ) *Flag
NewFlag creates a new Flag with allowed values.
Parameters:
defaultValue - the default value for the flag. value - pointer to a string to store the flag value (can be nil). allowed - slice of allowed string values. name - the flag name. usage - the usage description for the flag.
Returns:
A pointer to the created Flag.
func (*Flag) Default ¶ added in v0.3.4
Default returns the default value of the flag.
Returns:
The default value.
func (*Flag) IsDebug ¶ added in v0.2.0
IsDebug returns true if the current mode is debug.
Returns:
True if debug mode, false otherwise.
func (*Flag) IsDev ¶
IsDev returns true if the current mode is development.
Returns:
True if development mode, false otherwise.
func (*Flag) IsMigrate ¶ added in v0.3.3
IsMigrate returns true if the current mode is migration.
Returns:
True if migration mode, false otherwise.
Click to show internal directories.
Click to hide internal directories.