From de36c3860c7418b19398c0e7ca4f530d9e2dee53 Mon Sep 17 00:00:00 2001 From: Sean Smith Date: Sat, 3 Jun 2017 22:04:33 -0700 Subject: [PATCH 1/2] Allow setting a custom output file which will contain all types Fixes #9 --- jsonenums.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jsonenums.go b/jsonenums.go index 7d26291..c12b385 100644 --- a/jsonenums.go +++ b/jsonenums.go @@ -91,6 +91,7 @@ var ( typeNames = flag.String("type", "", "comma-separated list of type names; must be set") outputPrefix = flag.String("prefix", "", "prefix to be added to the output file") outputSuffix = flag.String("suffix", "_jsonenums", "suffix to be added to the output file") + outputFile = flag.String("file", "", "Specify the exact filename to output with. Will ignore output prefix/suffix values.") ) func main() { @@ -152,6 +153,10 @@ func main() { output := strings.ToLower(*outputPrefix + typeName + *outputSuffix + ".go") + if *outputFile != "" { + // This will make sure that .go is at the end whether or not a user specifies it + output = strings.TrimSuffix(*outputFile, ".go") + ".go" + } outputPath := filepath.Join(dir, output) if err := ioutil.WriteFile(outputPath, src, 0644); err != nil { log.Fatalf("writing output: %s", err) From 4cfca3d817998f0549ef3b3f4a89e55bdc037aa0 Mon Sep 17 00:00:00 2001 From: Sean Smith Date: Sat, 3 Jun 2017 22:07:53 -0700 Subject: [PATCH 2/2] Update the message for outputFile --- jsonenums.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsonenums.go b/jsonenums.go index c12b385..77207cf 100644 --- a/jsonenums.go +++ b/jsonenums.go @@ -91,7 +91,8 @@ var ( typeNames = flag.String("type", "", "comma-separated list of type names; must be set") outputPrefix = flag.String("prefix", "", "prefix to be added to the output file") outputSuffix = flag.String("suffix", "_jsonenums", "suffix to be added to the output file") - outputFile = flag.String("file", "", "Specify the exact filename to output with. Will ignore output prefix/suffix values.") + outputFile = flag.String("file", "", "Specify the exact filename to output with. "+ + "Will ignore output prefix/suffix values. This option should be used if multiple types are set") ) func main() {