X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=cmd%2Fbinapi-generator%2Fmain.go;h=b3a131c9e194b4d1ed3d55cd07f618bc89c23649;hb=fa21c9d726ebb807895a8571af9a16dab5cd8d6e;hp=b73a6993e41475e85db81ab57c982a847921afa4;hpb=08ddeac03fd3832d44a3dfb48ee85ecd95d2b388;p=govpp.git diff --git a/cmd/binapi-generator/main.go b/cmd/binapi-generator/main.go index b73a699..b3a131c 100644 --- a/cmd/binapi-generator/main.go +++ b/cmd/binapi-generator/main.go @@ -30,27 +30,15 @@ import ( ) var ( - inputFile = flag.String("input-file", "", "Input JSON file.") - inputDir = flag.String("input-dir", ".", "Input directory with JSON files.") + inputFile = flag.String("input-file", "", "Input file with VPP API in JSON format.") + inputDir = flag.String("input-dir", ".", "Input directory with VPP API files in JSON format.") outputDir = flag.String("output-dir", ".", "Output directory where package folders will be generated.") - includeAPIVer = flag.Bool("include-apiver", false, "Whether to include VlAPIVersion in generated file.") - debug = flag.Bool("debug", false, "Turn on debug mode.") - continueOnError = flag.Bool("continue-onerror", false, "Wheter to continue with next file on error.") + includeAPIVer = flag.Bool("include-apiver", false, "Include APIVersion constant for each module.") + includeComments = flag.Bool("include-comments", false, "Include JSON API source in comments for each object.") + continueOnError = flag.Bool("continue-onerror", false, "Continue with next file on error.") + debug = flag.Bool("debug", false, "Enable debug mode.") ) -func init() { - flag.Parse() - if *debug { - logrus.SetLevel(logrus.DebugLevel) - } -} - -func logf(f string, v ...interface{}) { - if *debug { - logrus.Debugf(f, v...) - } -} - var log = logrus.Logger{ Level: logrus.InfoLevel, Formatter: &logrus.TextFormatter{}, @@ -58,6 +46,11 @@ var log = logrus.Logger{ } func main() { + flag.Parse() + if *debug { + logrus.SetLevel(logrus.DebugLevel) + } + if *inputFile == "" && *inputDir == "" { fmt.Fprintln(os.Stderr, "ERROR: input-file or input-dir must be specified") os.Exit(1) @@ -112,6 +105,9 @@ func generateFromFile(inputFile, outputDir string) error { return err } + ctx.includeAPIVersionCrc = *includeAPIVer + ctx.includeComments = *includeComments + // read input file contents ctx.inputData, err = readFile(inputFile) if err != nil { @@ -182,3 +178,9 @@ func parseJSON(inputData []byte) (*jsongo.JSONNode, error) { return &root, nil } + +func logf(f string, v ...interface{}) { + if *debug { + logrus.Debugf(f, v...) + } +}