mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-31 13:57:26 -08:00
fix(export): format overrules file extension
This commit is contained in:
parent
87d1719bd0
commit
5b7b4afec9
|
@ -2,6 +2,7 @@ package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -42,15 +43,29 @@ Exports the ~/myconfig.omp.json config file to toml and prints the result to std
|
||||||
env.Init()
|
env.Init()
|
||||||
defer env.Close()
|
defer env.Close()
|
||||||
cfg := engine.LoadConfig(env)
|
cfg := engine.LoadConfig(env)
|
||||||
|
|
||||||
if len(output) == 0 {
|
if len(output) == 0 {
|
||||||
fmt.Print(cfg.Export(format))
|
fmt.Print(cfg.Export(format))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg.Output = cleanOutputPath(output, env)
|
cfg.Output = cleanOutputPath(output, env)
|
||||||
format := strings.TrimPrefix(filepath.Ext(output), ".")
|
|
||||||
if format == "yml" {
|
if len(format) == 0 {
|
||||||
format = engine.YAML
|
format = strings.TrimPrefix(filepath.Ext(output), ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch format {
|
||||||
|
case "json", "jsonc":
|
||||||
|
format = engine.JSON
|
||||||
|
case "toml", "tml":
|
||||||
|
format = engine.TOML
|
||||||
|
case "yaml", "yml":
|
||||||
|
format = engine.YAML
|
||||||
|
default:
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
cfg.Write(format)
|
cfg.Write(format)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue