debug: add an mtree.Debugf and -debug flag

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2016-07-20 13:28:08 -04:00
parent 39f68f5be2
commit ed6b293839
4 changed files with 26 additions and 3 deletions

View file

@ -23,6 +23,8 @@ var (
flListKeywords = flag.Bool("list-keywords", false, "List the keywords available")
flResultFormat = flag.String("result-format", "bsd", "output the validation results using the given format (bsd, json, path)")
flTar = flag.String("T", "", "use tar archive to create or validate a directory hierarchy spec")
flDebug = flag.Bool("debug", false, "output debug info to STDERR")
)
var formats = map[string]func(*mtree.Result) string{
@ -57,6 +59,10 @@ var formats = map[string]func(*mtree.Result) string{
func main() {
flag.Parse()
if *flDebug {
os.Setenv("DEBUG", "1")
}
// so that defers cleanly exec
var isErr bool
defer func() {