X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=cmd%2Fbinapi-generator%2Fmain.go;h=a730df4944355e90f2559e5d6b82076db3ccae2b;hb=c94a962279858fb13eaacc689f47aed358373e44;hp=af6062838fd1d6ea7e8ab6bed25febff4c98378d;hpb=42d11af03300fe0a3476c32ad8c70297862d9320;p=govpp.git 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 \"/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 {