Skip to content

Commit

Permalink
fix(notice): validate correct keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Nov 4, 2024
1 parent 075eaca commit 65799f7
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/cli/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
)

var (
toggleUse = "%s [notice]"
toggleUse = "%s [upgradenotice]"
toggleLong = `%s a feature
This command is used to %s one of the following features:
- notice`
- upgradenotice`
toggleArgs = []string{
config.UPGRADENOTICE,
config.AUTOUPGRADE,
Expand Down Expand Up @@ -54,24 +54,15 @@ func toggleFeature(cmd *cobra.Command, feature string, enable bool) {
env.Init()
defer env.Close()

var key string

switch feature {
case "notice":
key = config.UPGRADENOTICE
case "autoupgrade":
key = config.AUTOUPGRADE
}

if len(key) == 0 {
if len(feature) == 0 {
_ = cmd.Help()
return
}

if enable {
env.Cache().Set(key, "true", cache.INFINITE)
env.Cache().Set(feature, "true", cache.INFINITE)
return
}

env.Cache().Delete(key)
env.Cache().Delete(feature)
}

0 comments on commit 65799f7

Please sign in to comment.