mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
parent
4be054dd4b
commit
9fbc61561d
|
@ -3,6 +3,8 @@ package cli
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/cache"
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/config"
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/runtime"
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/upgrade"
|
||||
|
||||
|
@ -18,6 +20,7 @@ This command is used to %s one of the following features:
|
|||
- notice`
|
||||
toggleArgs = []string{
|
||||
"notice",
|
||||
"autoupgrade",
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -59,7 +62,14 @@ func toggleFeature(cmd *cobra.Command, feature string, enable bool) {
|
|||
return
|
||||
}
|
||||
|
||||
env.Cache().Set(upgrade.CACHEKEY, "disabled", -1)
|
||||
env.Cache().Set(upgrade.CACHEKEY, "disabled", cache.INFINITE)
|
||||
case "autoupgrade":
|
||||
if enable {
|
||||
env.Cache().Set(config.AUTOUPGRADE, "true", cache.INFINITE)
|
||||
return
|
||||
}
|
||||
|
||||
env.Cache().Delete(config.AUTOUPGRADE)
|
||||
default:
|
||||
_ = cmd.Help()
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ const (
|
|||
YAML string = "yaml"
|
||||
TOML string = "toml"
|
||||
|
||||
AUTOUPGRADE = "auto_upgrade"
|
||||
|
||||
Version = 2
|
||||
)
|
||||
|
||||
|
@ -103,11 +105,16 @@ func (cfg *Config) Features() shell.Features {
|
|||
feats = append(feats, shell.FTCSMarks)
|
||||
}
|
||||
|
||||
if !cfg.AutoUpgrade && !cfg.DisableNotice {
|
||||
autoUpgrade := cfg.AutoUpgrade
|
||||
if _, OK := cfg.env.Cache().Get(AUTOUPGRADE); OK {
|
||||
autoUpgrade = true
|
||||
}
|
||||
|
||||
if !autoUpgrade && !cfg.DisableNotice {
|
||||
feats = append(feats, shell.Notice)
|
||||
}
|
||||
|
||||
if cfg.AutoUpgrade {
|
||||
if autoUpgrade {
|
||||
feats = append(feats, shell.Upgrade)
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ const (
|
|||
A new release of Oh My Posh is available: %s → %s
|
||||
To upgrade, run: 'oh-my-posh upgrade'
|
||||
|
||||
To enable automated upgrades, set 'auto_upgrade' to 'true' in your configuration.
|
||||
To enable automated upgrades, run: 'oh-my-posh enable autoupgrade'.
|
||||
`
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue