mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-31 13:57:26 -08:00
parent
8dada3cbaf
commit
94a379b26a
|
@ -12,6 +12,7 @@ import (
|
|||
var (
|
||||
print bool
|
||||
strict bool
|
||||
manual bool
|
||||
|
||||
initCmd = &cobra.Command{
|
||||
Use: "init [bash|zsh|fish|powershell|pwsh|cmd|nu] --config ~/.mytheme.omp.json",
|
||||
|
@ -42,6 +43,7 @@ See the documentation to initialize your shell: https://ohmyposh.dev/docs/instal
|
|||
func init() { //nolint:gochecknoinits
|
||||
initCmd.Flags().BoolVarP(&print, "print", "p", false, "print the init script")
|
||||
initCmd.Flags().BoolVarP(&strict, "strict", "s", false, "run in strict mode")
|
||||
initCmd.Flags().BoolVarP(&manual, "manual", "m", false, "enable/disable manual mode")
|
||||
_ = initCmd.MarkPersistentFlagRequired("config")
|
||||
rootCmd.AddCommand(initCmd)
|
||||
}
|
||||
|
@ -53,6 +55,7 @@ func runInit(shellName string) {
|
|||
Shell: shellName,
|
||||
Config: config,
|
||||
Strict: strict,
|
||||
Manual: manual,
|
||||
},
|
||||
}
|
||||
env.Init()
|
||||
|
|
|
@ -54,6 +54,7 @@ type Flags struct {
|
|||
TerminalWidth int
|
||||
Strict bool
|
||||
Debug bool
|
||||
Manual bool
|
||||
}
|
||||
|
||||
type CommandError struct {
|
||||
|
|
|
@ -174,6 +174,14 @@ func PrintInit(env environment.Environment) string {
|
|||
if err != nil {
|
||||
return noExe
|
||||
}
|
||||
|
||||
toggleSetting := func(setting bool) string {
|
||||
if env.Flags().Manual {
|
||||
return "false"
|
||||
}
|
||||
return strconv.FormatBool(setting)
|
||||
}
|
||||
|
||||
shell := env.Flags().Shell
|
||||
configFile := env.Flags().Config
|
||||
var script string
|
||||
|
@ -209,9 +217,9 @@ func PrintInit(env environment.Environment) string {
|
|||
"::OMP::", executable,
|
||||
"::CONFIG::", configFile,
|
||||
"::SHELL::", shell,
|
||||
"::TRANSIENT::", strconv.FormatBool(Transient),
|
||||
"::ERROR_LINE::", strconv.FormatBool(ErrorLine),
|
||||
"::TOOLTIPS::", strconv.FormatBool(Tooltips),
|
||||
"::TRANSIENT::", toggleSetting(Transient),
|
||||
"::ERROR_LINE::", toggleSetting(ErrorLine),
|
||||
"::TOOLTIPS::", toggleSetting(Tooltips),
|
||||
).Replace(script)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue