summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2018-08-24 09:36:48 -0400
committerDave Henderson <dhenderson@gmail.com>2018-08-28 12:50:48 -0400
commit92aabdb1e7796a136675ab110ae81a2cdab02179 (patch)
treea74acb61aa5fe155af0fe03dc9710d66f8dd8de0 /cmd
parentc0201760ff6cd9acd992eb7e96f447c401fd3178 (diff)
Adding new --verbose flag
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gomplate/main.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/cmd/gomplate/main.go b/cmd/gomplate/main.go
index 5aa0727c..db12d4fc 100644
--- a/cmd/gomplate/main.go
+++ b/cmd/gomplate/main.go
@@ -14,6 +14,7 @@ import (
var (
printVer bool
+ verbose bool
opts gomplate.Config
)
@@ -42,7 +43,6 @@ func validateOpts(cmd *cobra.Command, args []string) error {
}
func printVersion(name string) {
- // fmt.Printf("%s version %s, build %s\n", name, version.Version, version.GitCommit)
fmt.Printf("%s version %s\n", name, version.Version)
}
@@ -80,10 +80,19 @@ func newGomplateCmd() *cobra.Command {
printVersion(cmd.Name())
return nil
}
+ if verbose {
+ fmt.Fprintf(os.Stderr, "%s version %s, build %s (%v)\nconfig is:\n%s\n\n",
+ cmd.Name(), version.Version, version.GitCommit, version.BuildDate,
+ &opts)
+ }
err := gomplate.RunTemplates(&opts)
cmd.SilenceErrors = true
cmd.SilenceUsage = true
+ if verbose {
+ fmt.Fprintf(os.Stderr, "rendered %d template(s) with %d error(s) in %v\n",
+ gomplate.Metrics.TemplatesProcessed, gomplate.Metrics.Errors, gomplate.Metrics.TotalRenderDuration)
+ }
return err
},
PostRunE: postRunExec,
@@ -113,6 +122,8 @@ func initFlags(command *cobra.Command) {
command.Flags().StringVar(&opts.LDelim, "left-delim", ldDefault, "override the default left-`delimiter` [$GOMPLATE_LEFT_DELIM]")
command.Flags().StringVar(&opts.RDelim, "right-delim", rdDefault, "override the default right-`delimiter` [$GOMPLATE_RIGHT_DELIM]")
+ command.Flags().BoolVarP(&verbose, "verbose", "V", false, "output extra information about what gomplate is doing")
+
command.Flags().BoolVarP(&printVer, "version", "v", false, "print the version")
}