mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 04:19:41 -08:00
fix(export): fail on invalid config option
This commit is contained in:
parent
05fe2e4159
commit
fb16d7c417
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/engine"
|
||||
|
@ -49,6 +50,12 @@ Exports the ~/myconfig.omp.json config file to toml and prints the result to std
|
|||
os.Exit(2)
|
||||
}
|
||||
|
||||
formats := []string{"json", "jsonc", "toml", "tml", "yaml", "yml"}
|
||||
if len(format) != 0 && !slices.Contains(formats, format) {
|
||||
// usage error
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
if len(output) == 0 {
|
||||
fmt.Print(cfg.Export(format))
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue