mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-23 09:01:44 -08:00
fix(cli): revert breaking CLI change
This commit is contained in:
parent
7de2809187
commit
466f9e72b8
|
@ -51,43 +51,7 @@ See the documentation to initialize your shell: https://ohmyposh.dev/docs/instal
|
|||
return
|
||||
}
|
||||
|
||||
var startTime time.Time
|
||||
if debug {
|
||||
startTime = time.Now()
|
||||
}
|
||||
|
||||
env := &runtime.Terminal{
|
||||
CmdFlags: &runtime.Flags{
|
||||
Shell: args[0],
|
||||
Config: configFlag,
|
||||
Strict: strict,
|
||||
Debug: debug,
|
||||
},
|
||||
}
|
||||
|
||||
env.Init()
|
||||
defer env.Close()
|
||||
|
||||
template.Init(env)
|
||||
|
||||
cfg := config.Load(env)
|
||||
|
||||
feats := cfg.Features()
|
||||
|
||||
var output string
|
||||
|
||||
switch {
|
||||
case printOutput, debug:
|
||||
output = shell.PrintInit(env, feats, &startTime)
|
||||
default:
|
||||
output = shell.Init(env, feats)
|
||||
}
|
||||
|
||||
if silent {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Print(output)
|
||||
runInit(args[0])
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -99,3 +63,43 @@ See the documentation to initialize your shell: https://ohmyposh.dev/docs/instal
|
|||
|
||||
return initCmd
|
||||
}
|
||||
|
||||
func runInit(sh string) {
|
||||
var startTime time.Time
|
||||
if debug {
|
||||
startTime = time.Now()
|
||||
}
|
||||
|
||||
env := &runtime.Terminal{
|
||||
CmdFlags: &runtime.Flags{
|
||||
Shell: sh,
|
||||
Config: configFlag,
|
||||
Strict: strict,
|
||||
Debug: debug,
|
||||
},
|
||||
}
|
||||
|
||||
env.Init()
|
||||
defer env.Close()
|
||||
|
||||
template.Init(env)
|
||||
|
||||
cfg := config.Load(env)
|
||||
|
||||
feats := cfg.Features()
|
||||
|
||||
var output string
|
||||
|
||||
switch {
|
||||
case printOutput, debug:
|
||||
output = shell.PrintInit(env, feats, &startTime)
|
||||
default:
|
||||
output = shell.Init(env, feats)
|
||||
}
|
||||
|
||||
if silent {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Print(output)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package cli
|
|||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -10,6 +11,8 @@ var (
|
|||
configFlag string
|
||||
shellName string
|
||||
silent bool
|
||||
// Deprecated flags, should be kept to avoid breaking CLI integration.
|
||||
initialize bool
|
||||
)
|
||||
|
||||
var RootCmd = &cobra.Command{
|
||||
|
@ -20,6 +23,11 @@ It can use the same configuration everywhere to offer a consistent
|
|||
experience, regardless of where you are. For a detailed guide
|
||||
on getting started, have a look at the docs at https://ohmyposh.dev`,
|
||||
Run: func(cmd *cobra.Command, _ []string) {
|
||||
if initialize {
|
||||
runInit(strings.ToLower(shellName))
|
||||
return
|
||||
}
|
||||
|
||||
_ = cmd.Help()
|
||||
},
|
||||
}
|
||||
|
@ -34,6 +42,10 @@ func Execute() {
|
|||
func init() {
|
||||
RootCmd.PersistentFlags().StringVarP(&configFlag, "config", "c", "", "config file path")
|
||||
|
||||
// Deprecated flags, should be kept to avoid breaking CLI integration.
|
||||
RootCmd.Flags().BoolVarP(&initialize, "init", "i", false, "init")
|
||||
RootCmd.Flags().StringVarP(&shellName, "shell", "s", "", "shell")
|
||||
|
||||
// Hide flags that are deprecated or for internal use only.
|
||||
RootCmd.PersistentFlags().BoolVar(&silent, "silent", false, "do not print anything")
|
||||
_ = RootCmd.Flags().MarkHidden("silent")
|
||||
|
|
Loading…
Reference in a new issue