Added an help command to dump all options for completion

`bazel help completion` dump all options completion pattern
for each command, giving hints on the format of the completion
residue (e.g., `label`, `path`, `{a,enum}`, ...). This
dump can be used to generate completion scripts.

--
MOS_MIGRATED_REVID=90743024
diff --git a/src/main/java/com/google/devtools/common/options/OptionsParser.java b/src/main/java/com/google/devtools/common/options/OptionsParser.java
index 9564daa..4eb5ce2 100644
--- a/src/main/java/com/google/devtools/common/options/OptionsParser.java
+++ b/src/main/java/com/google/devtools/common/options/OptionsParser.java
@@ -417,6 +417,29 @@
   }
 
   /**
+   * Returns a string listing the possible flag completion for this command along with the command
+   * completion if any. See {@link OptionsUsage#getCompletion(Field, StringBuilder)} for more
+   * details on the format for the flag completion.
+   */
+  public String getOptionsCompletion() {
+    StringBuilder desc = new StringBuilder();
+
+    // List all options
+    List<Field> allFields = Lists.newArrayList();
+    for (Class<? extends OptionsBase> optionsClass : impl.getOptionsClasses()) {
+      allFields.addAll(impl.getAnnotatedFieldsFor(optionsClass));
+    }
+    for (Field optionField : allFields) {
+      String category = optionField.getAnnotation(Option.class).category();
+      if (documentationLevel(category) == DocumentationLevel.DOCUMENTED) {
+        OptionsUsage.getCompletion(optionField, desc);
+      }
+    }
+
+    return desc.toString();
+  }
+
+  /**
    * Returns a description of the option value set by the last previous call to
    * {@link #parse(OptionPriority, String, List)} that successfully set the given
    * option. If the option is of type {@link List}, the description will