fix(cli): pass --eval flag of init command correctly for Elvish

This commit is contained in:
L. Yeung
2025-10-07 06:38:03 +02:00
committed by Jan De Dobbeleer
parent 5138df9c36
commit a79134e8ff
2 changed files with 6 additions and 3 deletions
+2 -2
View File
@@ -62,7 +62,7 @@ See the documentation to initialize your shell: https://ohmyposh.dev/docs/instal
initCmd.Flags().BoolVarP(&printOutput, "print", "p", false, "print the init script")
initCmd.Flags().BoolVarP(&strict, "strict", "s", false, "run in strict mode")
initCmd.Flags().BoolVar(&debug, "debug", false, "enable/disable debug mode")
initCmd.Flags().BoolVar(&eval, "eval", false, "output the prompt for eval")
initCmd.Flags().BoolVar(&eval, "eval", false, "output the full init script for eval")
_ = initCmd.MarkPersistentFlagRequired("config")
@@ -167,7 +167,7 @@ func getFullCommand(cmd *cobra.Command, args []string) string {
}
func initCache(sh string) {
if !printOutput && eval && sh == shell.PWSH {
if !printOutput && (sh == shell.PWSH || sh == shell.ELVISH) {
cache.Init(sh)
return
}
+4 -1
View File
@@ -58,6 +58,9 @@ func Init(env runtime.Environment, feats Features) string {
if env.Flags().Strict {
additionalParams += " --strict"
}
if env.Flags().Eval {
additionalParams += " --eval"
}
config := quotePwshOrElvishStr(env.Flags().ConfigPath)
executable = quotePwshOrElvishStr(executable)
@@ -66,7 +69,7 @@ func Init(env runtime.Environment, feats Features) string {
switch env.Flags().Shell {
case PWSH:
command = "(@(& %s init %s --config=%s --print --eval%s) -join \"`n\") | Invoke-Expression"
command = "(@(& %s init %s --config=%s --print%s) -join \"`n\") | Invoke-Expression"
case ELVISH:
command = "eval ((external %s) init %s --config=%s --print%s | slurp)"
}