Allow setting a custom output file which will contain all types
Fixes #9
This commit is contained in:
parent
7058b320c2
commit
de36c3860c
@ -91,6 +91,7 @@ var (
|
|||||||
typeNames = flag.String("type", "", "comma-separated list of type names; must be set")
|
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")
|
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")
|
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() {
|
func main() {
|
||||||
@ -152,6 +153,10 @@ func main() {
|
|||||||
|
|
||||||
output := strings.ToLower(*outputPrefix + typeName +
|
output := strings.ToLower(*outputPrefix + typeName +
|
||||||
*outputSuffix + ".go")
|
*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)
|
outputPath := filepath.Join(dir, output)
|
||||||
if err := ioutil.WriteFile(outputPath, src, 0644); err != nil {
|
if err := ioutil.WriteFile(outputPath, src, 0644); err != nil {
|
||||||
log.Fatalf("writing output: %s", err)
|
log.Fatalf("writing output: %s", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user