| 57 | } |
| 58 | |
| 59 | std::string FlatCompiler::GetUsageString(const char *program_name) const { |
| 60 | std::stringstream ss; |
| 61 | ss << "Usage: " << program_name << " [OPTION]... FILE... [-- FILE...]\n"; |
| 62 | for (size_t i = 0; i < params_.num_generators; ++i) { |
| 63 | const Generator &g = params_.generators[i]; |
| 64 | |
| 65 | std::stringstream full_name; |
| 66 | full_name << std::setw(16) << std::left << g.generator_opt_long; |
| 67 | const char *name = g.generator_opt_short ? g.generator_opt_short : " "; |
| 68 | const char *help = g.generator_help; |
| 69 | |
| 70 | ss << " " << full_name.str() << " " << name << " " << help << ".\n"; |
| 71 | } |
| 72 | // clang-format off |
| 73 | |
| 74 | // Output width |
| 75 | // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 |
| 76 | ss << |
| 77 | " -o PATH Prefix PATH to all generated files.\n" |
| 78 | " -I PATH Search for includes in the specified path.\n" |
| 79 | " -M Print make rules for generated files.\n" |
| 80 | " --version Print the version number of flatc and exit.\n" |
| 81 | " --strict-json Strict JSON: field names must be / will be quoted,\n" |
| 82 | " no trailing commas in tables/vectors.\n" |
| 83 | " --allow-non-utf8 Pass non-UTF-8 input through parser and emit nonstandard\n" |
| 84 | " \\x escapes in JSON. (Default is to raise parse error on\n" |
| 85 | " non-UTF-8 input.)\n" |
| 86 | " --natural-utf8 Output strings with UTF-8 as human-readable strings.\n" |
| 87 | " By default, UTF-8 characters are printed as \\uXXXX escapes.\n" |
| 88 | " --defaults-json Output fields whose value is the default when\n" |
| 89 | " writing JSON\n" |
| 90 | " --unknown-json Allow fields in JSON that are not defined in the\n" |
| 91 | " schema. These fields will be discared when generating\n" |
| 92 | " binaries.\n" |
| 93 | " --no-prefix Don\'t prefix enum values with the enum type in C++.\n" |
| 94 | " --scoped-enums Use C++11 style scoped and strongly typed enums.\n" |
| 95 | " also implies --no-prefix.\n" |
| 96 | " --gen-includes (deprecated), this is the default behavior.\n" |
| 97 | " If the original behavior is required (no include\n" |
| 98 | " statements) use --no-includes.\n" |
| 99 | " --no-includes Don\'t generate include statements for included\n" |
| 100 | " schemas the generated file depends on (C++ / Python).\n" |
| 101 | " --gen-mutable Generate accessors that can mutate buffers in-place.\n" |
| 102 | " --gen-onefile Generate single output file for C# and Go.\n" |
| 103 | " --gen-name-strings Generate type name functions for C++ and Rust.\n" |
| 104 | " --gen-object-api Generate an additional object-based API.\n" |
| 105 | " --gen-compare Generate operator== for object-based API types.\n" |
| 106 | " --gen-nullable Add Clang _Nullable for C++ pointer. or @Nullable for Java\n" |
| 107 | " --java-checkerframe work Add @Pure for Java.\n" |
| 108 | " --gen-generated Add @Generated annotation for Java\n" |
| 109 | " --gen-jvmstatic Add @JvmStatic annotation for Kotlin methods\n" |
| 110 | " in companion object for interop from Java to Kotlin.\n" |
| 111 | " --gen-all Generate not just code for the current schema files,\n" |
| 112 | " but for all files it includes as well.\n" |
| 113 | " If the language uses a single file for output (by default\n" |
| 114 | " the case for C++ and JS), all code will end up in this one\n" |
| 115 | " file.\n" |
| 116 | " --cpp-include Adds an #include in generated file.\n" |