cmd/inputs: added --all option to list

Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
Sam Alba 2021-05-21 17:39:17 -07:00
parent 6b73de7ea3
commit a8837aaaed

View File

@ -51,7 +51,7 @@ var listCmd = &cobra.Command{
inputs := lDeploy.ScanInputs(ctx) inputs := lDeploy.ScanInputs(ctx)
w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0)
fmt.Fprintln(w, "Input\tType\tValue\tSet by user\tSet in plan") fmt.Fprintln(w, "Input\tType\tValue\tSet by user")
for _, inp := range inputs { for _, inp := range inputs {
isConcrete := (inp.IsConcreteR() == nil) isConcrete := (inp.IsConcreteR() == nil)
@ -64,12 +64,18 @@ var listCmd = &cobra.Command{
valStr = fmt.Sprintf("%s (default)", valStr) valStr = fmt.Sprintf("%s (default)", valStr)
} }
fmt.Fprintf(w, "%s\t%s\t%s\t%t\t%t\n", if !viper.GetBool("all") {
// skip input that is not overridable
if !hasDefault && isConcrete {
continue
}
}
fmt.Fprintf(w, "%s\t%s\t%s\t%t\n",
inp.Path(), inp.Path(),
getType(inp), getType(inp),
valStr, valStr,
isUserSet(environment, inp), isUserSet(environment, inp),
isConcrete,
) )
} }
@ -105,6 +111,8 @@ func getType(val *compiler.Value) string {
} }
func init() { func init() {
listCmd.Flags().BoolP("all", "a", false, "List all inputs (include non-overridable)")
if err := viper.BindPFlags(listCmd.Flags()); err != nil { if err := viper.BindPFlags(listCmd.Flags()); err != nil {
panic(err) panic(err)
} }