summaryrefslogtreecommitdiff
path: root/gomplate.go
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 /gomplate.go
parentc0201760ff6cd9acd992eb7e96f447c401fd3178 (diff)
Adding new --verbose flag
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'gomplate.go')
-rw-r--r--gomplate.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/gomplate.go b/gomplate.go
index bca66f75..184af240 100644
--- a/gomplate.go
+++ b/gomplate.go
@@ -4,6 +4,7 @@ import (
"io"
"os"
"strconv"
+ "strings"
"text/template"
"time"
@@ -39,6 +40,48 @@ func (o *Config) getMode() (os.FileMode, bool, error) {
return mode, modeOverride, nil
}
+// nolint: gocyclo
+func (o *Config) String() string {
+ c := "input: "
+ if o.Input != "" {
+ c += "<arg>"
+ } else if o.InputDir != "" {
+ c += o.InputDir
+ } else if len(o.InputFiles) > 0 {
+ c += strings.Join(o.InputFiles, ", ")
+ }
+
+ if len(o.ExcludeGlob) > 0 {
+ c += "\nexclude: " + strings.Join(o.ExcludeGlob, ", ")
+ }
+
+ c += "\noutput: "
+ if o.InputDir != "" && o.OutputDir != "." {
+ c += o.OutputDir
+ } else if len(o.OutputFiles) > 0 {
+ c += strings.Join(o.OutputFiles, ", ")
+ }
+
+ if o.OutMode != "" {
+ c += "\nchmod: " + o.OutMode
+ }
+
+ if len(o.DataSources) > 0 {
+ c += "\ndatasources: " + strings.Join(o.DataSources, ", ")
+ }
+ if len(o.DataSourceHeaders) > 0 {
+ c += "\ndatasourceheaders: " + strings.Join(o.DataSourceHeaders, ", ")
+ }
+
+ if o.LDelim != "{{" {
+ c += "\nleft_delim: " + o.LDelim
+ }
+ if o.RDelim != "}}" {
+ c += "\nright_delim: " + o.RDelim
+ }
+ return c
+}
+
// gomplate -
type gomplate struct {
funcMap template.FuncMap