aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/binapi-generator/main.go
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2019-02-08 01:16:32 +0100
committerOndrej Fabry <ofabry@cisco.com>2019-02-08 01:16:32 +0100
commitfa21c9d726ebb807895a8571af9a16dab5cd8d6e (patch)
tree4597d483f90e374e89f3923324b531a56217a0f9 /cmd/binapi-generator/main.go
parent8ba70a7b13950593aab9863246f830eda450f06b (diff)
Generator improvements and cleanup
- generator now supports include-comments flag (as opt-in) - minor code cleanup in binapi-generator - remove obsolete unit tests - flatten examples from examples/cmd folder - introduce constant for checking compatibility in future versions Change-Id: I3545f2ba4b869a3b51d6d0de7e742f3f1e1be392 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'cmd/binapi-generator/main.go')
-rw-r--r--cmd/binapi-generator/main.go38
1 files changed, 20 insertions, 18 deletions
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...)
+ }
+}