aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2020-08-21 17:25:53 +0200
committerOndrej Fabry <ofabry@cisco.com>2020-09-03 15:11:13 +0000
commitc94a962279858fb13eaacc689f47aed358373e44 (patch)
tree0cade1807c10ed53bf7c1b623f4d26da639356f6 /cmd
parent42d11af03300fe0a3476c32ad8c70297862d9320 (diff)
Improve doc & fix import ordering
This also updates /binapi and adds a new make command to generate api files out of a local vpp repo clone Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com> Change-Id: Iff7965388a74ecd21af80f10b5a59d4ed8da6340
Diffstat (limited to 'cmd')
-rw-r--r--cmd/binapi-generator/main.go29
1 files changed, 21 insertions, 8 deletions
diff --git a/cmd/binapi-generator/main.go b/cmd/binapi-generator/main.go
index af60628..a730df4 100644
--- a/cmd/binapi-generator/main.go
+++ b/cmd/binapi-generator/main.go
@@ -31,20 +31,34 @@ import (
func init() {
flag.Usage = func() {
- fmt.Fprintf(os.Stderr, "Usage: %s [OPTION] API_FILES\n", os.Args[0])
- fmt.Fprintln(os.Stderr, "Provide API_FILES by file name, or with full path including extension.")
- fmt.Fprintln(os.Stderr, "Parse API_FILES and generate Go bindings based on the options given:")
+ fmt.Fprintf(os.Stderr, "USAGE\n")
+ fmt.Fprintf(os.Stderr, " Parse API_FILES and generate Go bindings\n")
+ fmt.Fprintf(os.Stderr, " Provide API_FILES by file name, or with full path including extension.\n")
+ fmt.Fprintf(os.Stderr, " %s [OPTION] API_FILES\n\n", os.Args[0])
+ fmt.Fprintf(os.Stderr, "OPTIONS\n")
flag.PrintDefaults()
+ fmt.Fprintf(os.Stderr, "\nEXAMPLES:\n")
+ fmt.Fprintf(os.Stderr, " %s \\\n", os.Args[0])
+ fmt.Fprintf(os.Stderr, " --input-dir=$VPP/build-root/install-vpp-native/vpp/share/vpp/api/ \\\n")
+ fmt.Fprintf(os.Stderr, " --output-dir=~/output \\\n")
+ fmt.Fprintf(os.Stderr, " interface ip\n")
+ fmt.Fprintf(os.Stderr, " Assuming --input-dir contains interface.api.json & ip.api.json\n")
}
}
+func printErrorAndExit(msg string) {
+ fmt.Fprintf(os.Stderr, "Error: %s\n\n", msg)
+ flag.Usage()
+ os.Exit(1)
+}
+
func main() {
var (
- theApiDir = flag.String("input-dir", vppapi.DefaultDir, "Input directory containing API files.")
- theInputFile = flag.String("input-file", "", "DEPRECATED: Use program arguments to define files to generate.")
+ theApiDir = flag.String("input-dir", vppapi.DefaultDir, "Input directory containing API files. (e.g. )")
theOutputDir = flag.String("output-dir", "binapi", "Output directory where code will be generated.")
- importPrefix = flag.String("import-prefix", "", "Define import path prefix to be used to import types.")
+ importPrefix = flag.String("import-prefix", "", "Prefix imports in the generated go code. \nE.g. other API Files (e.g. api_file.ba.go) will be imported with :\nimport (\n api_file \"<import-prefix>/api_file\"\n)")
generatorPlugins = flag.String("gen", "rpc", "List of generator plugins to run for files.")
+ theInputFile = flag.String("input-file", "", "DEPRECATED: Use program arguments to define files to generate.")
printVersion = flag.Bool("version", false, "Prints version and exits.")
debugLog = flag.Bool("debug", false, "Enable verbose logging.")
@@ -65,8 +79,7 @@ func main() {
var filesToGenerate []string
if *theInputFile != "" {
if flag.NArg() > 0 {
- fmt.Fprintln(os.Stderr, "input-file cannot be combined with files to generate in arguments")
- os.Exit(1)
+ printErrorAndExit("input-file cannot be combined with files to generate in arguments")
}
filesToGenerate = append(filesToGenerate, *theInputFile)
} else {