Added long form options for all generators (--cpp etc.)

Short-form versions are still supported, but are deprecated.

Change-Id: I15f70ca8d69ba5790368205caa9603b65e1b7fff
Tested: on Linux.
diff --git a/docs/html/md__compiler.html b/docs/html/md__compiler.html
index 2fe560d..ff3f7fe 100644
--- a/docs/html/md__compiler.html
+++ b/docs/html/md__compiler.html
@@ -61,18 +61,28 @@
 <div class="title">Using the schema compiler </div>  </div>
 </div><!--header-->
 <div class="contents">
-<div class="textblock"><p>Usage: </p><pre class="fragment">flatc [ -c ] [ -j ] [ -b ] [ -t ] [ -o PATH ] [ -I PATH ] [ -S ] FILES...
+<div class="textblock"><p>Usage: </p><pre class="fragment">flatc [ GENERATOR OPTIONS ] [ -o PATH ] [ -I PATH ] [ -S ] FILES...
       [ -- FILES...]
 </pre><p>The files are read and parsed in order, and can contain either schemas or data (see below). Later files can make use of definitions in earlier files.</p>
 <p><code>--</code> indicates that the following files are binary files in FlatBuffer format conforming to the schema(s) indicated before it. Incompatible binary files currently will give unpredictable results (!)</p>
 <p>Depending on the flags passed, additional files may be generated for each file processed:</p>
+<p>For any schema input files, one or more generators can be specified:</p>
 <ul>
-<li><code>-c</code> : Generate a C++ header for all definitions in this file (as <code>filename_generated.h</code>). Skipped for data.</li>
-<li><code>-j</code> : Generate Java classes. Skipped for data.</li>
-<li><code>-n</code> : Generate C# classes. Skipped for data.</li>
-<li><code>-g</code> : Generate Go classes. Skipped for data.</li>
-<li><code>-b</code> : If data is contained in this file, generate a <code>filename.bin</code> containing the binary flatbuffer.</li>
-<li><code>-t</code> : If data is contained in this file, generate a <code>filename.json</code> representing the data in the flatbuffer.</li>
+<li><code>--cpp</code>, <code>-c</code> : Generate a C++ header for all definitions in this file (as <code>filename_generated.h</code>).</li>
+<li><code>--java</code>, <code>-j</code> : Generate Java code.</li>
+<li><code>--csharp</code>, <code>-n</code> : Generate C# code.</li>
+<li><code>--go</code>, <code>-g</code> : Generate Go code.</li>
+<li><code>--python</code>, <code>-p</code>: Generate Python code.</li>
+<li><code>--javascript</code>, <code>-s</code>: Generate JavaScript code.</li>
+<li><code>--php</code>: Generate PHP code.</li>
+</ul>
+<p>For any data input files:</p>
+<ul>
+<li><code>--binary</code>, <code>-b</code> : If data is contained in this file, generate a <code>filename.bin</code> containing the binary flatbuffer (or a different extension if one is specified in the schema).</li>
+<li><code>--json</code>, <code>-t</code> : If data is contained in this file, generate a <code>filename.json</code> representing the data in the flatbuffer.</li>
+</ul>
+<p>Additional options:</p>
+<ul>
 <li><code>-o PATH</code> : Output all generated files to PATH (either absolute, or relative to the current directory). If omitted, PATH will be the current directory. PATH should end in your systems path separator, e.g. <code>/</code> or <code>\</code>.</li>
 <li><code>-I PATH</code> : when encountering <code>include</code> statements, attempt to load the files from this path. Paths will be tried in the order given, and if all fail (or none are specified) it will try to load relative to the path of the schema file being parsed.</li>
 <li><code>-M</code> : Print make rules for generated files.</li>
@@ -86,8 +96,9 @@
 <li><code>--gen-onefile</code> : Generate single output file (useful for C#)</li>
 <li><code>--raw-binary</code> : Allow binaries without a file_indentifier to be read. This may crash flatc given a mismatched schema.</li>
 <li><code>--proto</code>: Expect input files to be .proto files (protocol buffers). Output the corresponding .fbs file. Currently supports: <code>package</code>, <code>message</code>, <code>enum</code>, nested declarations, <code>import</code> (use <code>-I</code> for paths), <code>extend</code>, <code>oneof</code>, <code>group</code>. Does not support, but will skip without error: <code>option</code>, <code>service</code>, <code>extensions</code>, and most everything else.</li>
-<li><code>--schema</code>: Serialize schemas instead of JSON (use with -b). This will output a binary version of the specified schema that itself corresponds to the reflection/reflection.fbs schema. Loading this binary file is the basis for reflection functionality. </li>
+<li><code>--schema</code>: Serialize schemas instead of JSON (use with -b). This will output a binary version of the specified schema that itself corresponds to the reflection/reflection.fbs schema. Loading this binary file is the basis for reflection functionality.</li>
 </ul>
+<p>NOTE: short-form options for generators are deprecated, use the long form whenever possible. </p>
 </div></div><!-- contents -->
 </div><!-- doc-content -->
 <!-- Google Analytics -->
diff --git a/docs/source/Compiler.md b/docs/source/Compiler.md
index 4e6b799..27ddf52 100755
--- a/docs/source/Compiler.md
+++ b/docs/source/Compiler.md
@@ -2,7 +2,7 @@
 
 Usage:
 
-    flatc [ -c ] [ -j ] [ -b ] [ -t ] [ -o PATH ] [ -I PATH ] [ -S ] FILES...
+    flatc [ GENERATOR OPTIONS ] [ -o PATH ] [ -I PATH ] [ -S ] FILES...
           [ -- FILES...]
 
 The files are read and parsed in order, and can contain either schemas
@@ -16,21 +16,34 @@
 Depending on the flags passed, additional files may
 be generated for each file processed:
 
--   `-c` : Generate a C++ header for all definitions in this file (as
-    `filename_generated.h`). Skipped for data.
+For any schema input files, one or more generators can be specified:
 
--   `-j` : Generate Java classes. Skipped for data.
+-   `--cpp`, `-c` : Generate a C++ header for all definitions in this file (as
+    `filename_generated.h`).
 
--   `-n` : Generate C# classes. Skipped for data.
+-   `--java`, `-j` : Generate Java code.
 
--   `-g` : Generate Go classes. Skipped for data.
+-   `--csharp`, `-n` : Generate C# code.
 
--   `-b` : If data is contained in this file, generate a
-    `filename.bin` containing the binary flatbuffer.
+-   `--go`, `-g` : Generate Go code.
 
--   `-t` : If data is contained in this file, generate a
+-   `--python`, `-p`: Generate Python code.
+
+-   `--javascript`, `-s`: Generate JavaScript code.
+
+-   `--php`: Generate PHP code.
+
+For any data input files:
+
+-   `--binary`, `-b` : If data is contained in this file, generate a
+    `filename.bin` containing the binary flatbuffer (or a different extension
+    if one is specified in the schema).
+
+-   `--json`, `-t` : If data is contained in this file, generate a
     `filename.json` representing the data in the flatbuffer.
 
+Additional options:
+
 -   `-o PATH` : Output all generated files to PATH (either absolute, or
     relative to the current directory). If omitted, PATH will be the
     current directory. PATH should end in your systems path separator,
@@ -82,3 +95,6 @@
     output a binary version of the specified schema that itself corresponds
     to the reflection/reflection.fbs schema. Loading this binary file is the
     basis for reflection functionality.
+
+NOTE: short-form options for generators are deprecated, use the long form
+whenever possible.
diff --git a/src/flatc.cpp b/src/flatc.cpp
index 337ce5d..2479da1 100644
--- a/src/flatc.cpp
+++ b/src/flatc.cpp
@@ -28,7 +28,8 @@
                    const std::string &path,
                    const std::string &file_name,
                    const flatbuffers::GeneratorOptions &opts);
-  const char *generator_opt;
+  const char *generator_opt_short;
+  const char *generator_opt_long;
   const char *lang_name;
   flatbuffers::GeneratorOptions::Language lang;
   const char *generator_help;
@@ -40,41 +41,41 @@
 };
 
 const Generator generators[] = {
-  { flatbuffers::GenerateBinary,   "-b", "binary",
+  { flatbuffers::GenerateBinary,   "-b", "--binary", "binary",
     flatbuffers::GeneratorOptions::kMAX,
     "Generate wire format binaries for any data definitions",
     flatbuffers::BinaryMakeRule },
-  { flatbuffers::GenerateTextFile, "-t", "text",
+  { flatbuffers::GenerateTextFile, "-t", "--json", "text",
     flatbuffers::GeneratorOptions::kMAX,
     "Generate text output for any data definitions",
     flatbuffers::TextMakeRule },
-  { flatbuffers::GenerateCPP,      "-c", "C++",
+  { flatbuffers::GenerateCPP,      "-c", "--cpp", "C++",
     flatbuffers::GeneratorOptions::kMAX,
     "Generate C++ headers for tables/structs",
     flatbuffers::CPPMakeRule },
-  { flatbuffers::GenerateGo,       "-g", "Go",
+  { flatbuffers::GenerateGo,       "-g", "--go", "Go",
     flatbuffers::GeneratorOptions::kGo,
     "Generate Go files for tables/structs",
     flatbuffers::GeneralMakeRule },
-  { flatbuffers::GenerateGeneral,  "-j", "Java",
+  { flatbuffers::GenerateGeneral,  "-j", "--java", "Java",
     flatbuffers::GeneratorOptions::kJava,
     "Generate Java classes for tables/structs",
     flatbuffers::GeneralMakeRule },
-  { flatbuffers::GenerateJS,       "-s", "JavaScript",
+  { flatbuffers::GenerateJS,       "-s", "--js", "JavaScript",
     flatbuffers::GeneratorOptions::kMAX,
     "Generate JavaScript code for tables/structs",
     flatbuffers::JSMakeRule },
-  { flatbuffers::GenerateGeneral,  "-n", "C#",
+  { flatbuffers::GenerateGeneral,  "-n", "--csharp", "C#",
     flatbuffers::GeneratorOptions::kCSharp,
     "Generate C# classes for tables/structs",
     flatbuffers::GeneralMakeRule },
-  { flatbuffers::GeneratePython,   "-p", "Python",
+  { flatbuffers::GeneratePython,   "-p", "--python", "Python",
     flatbuffers::GeneratorOptions::kMAX,
     "Generate Python files for tables/structs",
     flatbuffers::GeneralMakeRule },
-    { flatbuffers::GeneratePhp,   "--php", "PHP",
+    { flatbuffers::GeneratePhp, nullptr, "--php", "PHP",
     flatbuffers::GeneratorOptions::kMAX,
-    "Generate Php files for tables/structs",
+    "Generate PHP files for tables/structs",
     flatbuffers::GeneralMakeRule },
 };
 
@@ -86,8 +87,11 @@
   if (usage) {
     printf("usage: %s [OPTION]... FILE... [-- FILE...]\n", program_name);
     for (size_t i = 0; i < sizeof(generators) / sizeof(generators[0]); ++i)
-      printf("  %s              %s.\n",
-             generators[i].generator_opt,
+      printf("  %-12s %s %s.\n",
+             generators[i].generator_opt_long,
+             generators[i].generator_opt_short
+               ? generators[i].generator_opt_short
+               : "  ",
              generators[i].generator_help);
     printf(
       "  -o PATH         Prefix PATH to all generated files.\n"
@@ -179,7 +183,9 @@
         print_make_rules = true;
       } else {
         for (size_t i = 0; i < num_generators; ++i) {
-          if (arg == generators[i].generator_opt) {
+          if (arg == generators[i].generator_opt_long ||
+              (generators[i].generator_opt_short &&
+               arg == generators[i].generator_opt_short)) {
             generator_enabled[i] = true;
             any_generator = true;
             goto found;
diff --git a/tests/generate_code.sh b/tests/generate_code.sh
index 91158bf..91661f3 100644
--- a/tests/generate_code.sh
+++ b/tests/generate_code.sh
@@ -1,2 +1,2 @@
-../flatc -c -j -n -g -b -p -s --php --gen-mutable --no-includes monster_test.fbs monsterdata_test.json
-../flatc -b --schema monster_test.fbs
+../flatc --cpp --java --csharp --go --binary --python --js --php --gen-mutable --no-includes monster_test.fbs monsterdata_test.json
+../flatc --binary --schema monster_test.fbs
diff --git a/tests/monster_test.bfbs b/tests/monster_test.bfbs
index 8d54ead..e5f51fa 100644
--- a/tests/monster_test.bfbs
+++ b/tests/monster_test.bfbs
Binary files differ
diff --git a/tests/monster_test_generated.js b/tests/monster_test_generated.js
index d46a9c6..9d0f48b 100644
--- a/tests/monster_test_generated.js
+++ b/tests/monster_test_generated.js
@@ -352,6 +352,8 @@
 };
 
 /**
+ * an example documentation comment: monster object
+ *
  * @constructor
  */
 MyGame.Example.Monster = function() {