Skip to content

Commit

Permalink
feat: Added Debug Mode to Mode Flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ralvarezdev committed Dec 18, 2024
1 parent 67fd45e commit 1c64765
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions mode/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const (

// Prod is the production mode
Prod = "prod"

// Debug is the debug mode
Debug = "debug"
)

// Flag is a custom flag type for mode
Expand All @@ -28,24 +31,29 @@ func NewFlag(defaultValue string, allowed []string) *Flag {
}
}

// IsDev returns true if the mode is development
// IsDev returns true if it's the development mode
func (m *Flag) IsDev() bool {
return m.Value() == Dev
}

// IsProd returns true if the mode is production
// IsProd returns true if it's the production mode
func (m *Flag) IsProd() bool {
return m.Value() == Prod
}

// IsDebug returns true if it's the debug mode
func (m *Flag) IsDebug() bool {
return m.Value() == Debug
}

// Mode is the environment mode
var Mode = NewFlag(Dev, []string{Dev, Prod})
var Mode = NewFlag(Dev, []string{Dev, Prod, Debug})

// SetFlag sets the mode flag
func SetFlag() {
flag.Var(
Mode,
Name,
"Specify mode. Allowed values are: dev, prod. Default is the development mode",
"Specify mode. Allowed values are: dev, prod, debug. Default is the development mode",
)
}

0 comments on commit 1c64765

Please sign in to comment.