From 977969a7e9d54baaf66016dd055ea0291c05e5f7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 31 Aug 2013 17:49:22 -0700 Subject: [PATCH] command/inspect: cleaner output if no required vars --- command/inspect/command.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/command/inspect/command.go b/command/inspect/command.go index 00ab16179..f82561083 100644 --- a/command/inspect/command.go +++ b/command/inspect/command.go @@ -48,15 +48,23 @@ func (c Command) Run(env packer.Environment, args []string) int { ui.Say("Variables:\n") ui.Say(" ") } else { - ui.Say("Required variables:\n") + requiredHeader := false for k, v := range tpl.Variables { if v.Required { + if !requiredHeader { + requiredHeader = true + ui.Say("Required variables:\n") + } + ui.Machine("template-variable", k, v.Default, "1") ui.Say(" " + k) } } - ui.Say("") + if requiredHeader { + ui.Say("") + } + ui.Say("Optional variables and their defaults:\n") keys := make([]string, 0, len(tpl.Variables)) max := 0