fix(export): fail on invalid config option

This commit is contained in:
Jan De Dobbeleer 2024-03-11 10:07:29 +01:00 committed by Jan De Dobbeleer
parent 05fe2e4159
commit fb16d7c417

View file

@ -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