Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions jsonenums.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +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. This option should be used if multiple types are set")
)

func main() {
Expand Down Expand Up @@ -152,6 +154,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)
Expand Down