From b2df8f62bc47adb58889b273434c9f16c03301d6 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sun, 29 May 2022 10:58:39 -0400 Subject: Simplify template processing Signed-off-by: Dave Henderson --- internal/cmd/config.go | 1 - internal/config/configfile.go | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'internal') diff --git a/internal/cmd/config.go b/internal/cmd/config.go index 6f0c3673..d48c6b63 100644 --- a/internal/cmd/config.go +++ b/internal/cmd/config.go @@ -25,7 +25,6 @@ var fs = afero.NewOsFs() // - creates a config.Config from the cobra flags // - creates a config.Config from the config file (if present) // - merges the two (flags take precedence) -// - validates the final config func loadConfig(cmd *cobra.Command, args []string) (*config.Config, error) { ctx := cmd.Context() flagConfig, err := cobraConfig(cmd, args) diff --git a/internal/config/configfile.go b/internal/config/configfile.go index ccc16227..1cd4a473 100644 --- a/internal/config/configfile.go +++ b/internal/config/configfile.go @@ -492,6 +492,16 @@ func isZero(value interface{}) bool { // ApplyDefaults - any defaults changed here should be added to cmd.InitFlags as // well for proper help/usage display. func (c *Config) ApplyDefaults() { + if c.Stdout == nil { + c.Stdout = os.Stdout + } + if c.Stderr == nil { + c.Stderr = os.Stderr + } + if c.Stdin == nil { + c.Stdin = os.Stdin + } + if c.InputDir != "" && c.OutputDir == "" && c.OutputMap == "" { c.OutputDir = "." } -- cgit v1.2.3