aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
authorGravatar ccalvarin <ccalvarin@google.com>2018-03-27 13:38:15 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-27 13:39:47 -0700
commit8bbb6c23d25b85fe13b41edd16010c2b5fafe2ea (patch)
tree590ce8e4b0d5583d8cf4cbdf084d75afc8b87b95 /src/main/java/com/google/devtools/build/lib
parent57203631fe71a7bebc8fb16b2d0f38fee8cc5139 (diff)
Remove old option categorization from the help output.
In preparation for removing all uses of the category field in Bazel options. RELNOTES: None. PiperOrigin-RevId: 190665669
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandUtils.java42
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java18
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java133
3 files changed, 30 insertions, 163 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandUtils.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandUtils.java
index 9e8bb80b35..652267448c 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandUtils.java
@@ -25,7 +25,6 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
/**
@@ -113,8 +112,6 @@ public class BlazeCommandUtils {
* @param topic the name of the help topic; used in %{command} expansion.
* @param help the text template of the help message. Certain %{x} variables will be expanded. A
* prefix of "resource:" means use the .jar resource of that name.
- * @param categoryDescriptions a mapping from option category names to descriptions, passed to
- * {@link OptionsParser#describeOptionsWithDeprecatedCategories}.
* @param helpVerbosity a tri-state verbosity option selecting between just names, names and
* syntax, and full description.
* @param productName the product name
@@ -124,29 +121,8 @@ public class BlazeCommandUtils {
String help,
Class<? extends BlazeCommand> commandClass,
Collection<Class<? extends OptionsBase>> options,
- Map<String, String> categoryDescriptions,
OptionsParser.HelpVerbosity helpVerbosity,
String productName) {
- return expandHelpTopic(
- topic,
- help,
- commandClass,
- options,
- categoryDescriptions,
- helpVerbosity,
- productName,
- false);
- }
-
- public static final String expandHelpTopic(
- String topic,
- String help,
- Class<? extends BlazeCommand> commandClass,
- Collection<Class<? extends OptionsBase>> options,
- Map<String, String> categoryDescriptions,
- OptionsParser.HelpVerbosity helpVerbosity,
- String productName,
- boolean useNewCategoryEnum) {
OptionsParser parser = OptionsParser.newOptionsParser(options);
String template;
@@ -171,15 +147,9 @@ public class BlazeCommandUtils {
}
String optionStr;
- if (useNewCategoryEnum) {
optionStr =
parser.describeOptions(productName, helpVerbosity).replace("%{product}", productName);
- } else {
- optionStr =
- parser
- .describeOptionsWithDeprecatedCategories(categoryDescriptions, helpVerbosity)
- .replace("%{product}", productName);
- }
+
return template
.replace("%{product}", productName)
.replace("%{command}", topic)
@@ -194,28 +164,22 @@ public class BlazeCommandUtils {
/**
* The help page for this command.
*
- * @param categoryDescriptions a mapping from option category names to descriptions, passed to
- * {@link OptionsParser#describeOptionsWithDeprecatedCategories}.
* @param verbosity a tri-state verbosity option selecting between just names, names and syntax,
* and full description.
*/
public static String getUsage(
Class<? extends BlazeCommand> commandClass,
- Map<String, String> categoryDescriptions,
OptionsParser.HelpVerbosity verbosity,
Iterable<BlazeModule> blazeModules,
ConfiguredRuleClassProvider ruleClassProvider,
- String productName,
- boolean useNewCategoryEnum) {
+ String productName) {
Command commandAnnotation = commandClass.getAnnotation(Command.class);
return BlazeCommandUtils.expandHelpTopic(
commandAnnotation.name(),
commandAnnotation.help(),
commandClass,
BlazeCommandUtils.getOptions(commandClass, blazeModules, ruleClassProvider),
- categoryDescriptions,
verbosity,
- productName,
- useNewCategoryEnum);
+ productName);
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java
index 82df3fb811..b7605e4b87 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java
@@ -209,17 +209,19 @@ public class DumpCommand implements BlazeCommand {
|| dumpOptions.skylarkMemory != null
|| (dumpOptions.dumpSkyframe != SkyframeDumpOption.OFF);
if (!anyOutput) {
- Map<String, String> categories = new HashMap<>();
- categories.put("verbosity", "Options that control what internal state is dumped");
Collection<Class<? extends OptionsBase>> optionList = new ArrayList<>();
optionList.add(DumpOptions.class);
- env.getReporter().getOutErr().printErrLn(BlazeCommandUtils.expandHelpTopic(
- getClass().getAnnotation(Command.class).name(),
- getClass().getAnnotation(Command.class).help(),
- getClass(),
- optionList, categories, OptionsParser.HelpVerbosity.LONG,
- runtime.getProductName()));
+ env.getReporter()
+ .getOutErr()
+ .printErrLn(
+ BlazeCommandUtils.expandHelpTopic(
+ getClass().getAnnotation(Command.class).name(),
+ getClass().getAnnotation(Command.class).help(),
+ getClass(),
+ optionList,
+ OptionsParser.HelpVerbosity.LONG,
+ runtime.getProductName()));
return BlazeCommandResult.exitCode(ExitCode.ANALYSIS_FAILURE);
}
PrintStream out = new PrintStream(env.getReporter().getOutErr().getOutputStream());
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java
index 6f47e3d1fb..4de7cbf5f8 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java
@@ -48,6 +48,7 @@ import com.google.devtools.common.options.OptionFilterDescriptions;
import com.google.devtools.common.options.OptionMetadataTag;
import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsParser;
+import com.google.devtools.common.options.OptionsParser.HelpVerbosity;
import com.google.devtools.common.options.OptionsProvider;
import java.util.ArrayList;
import java.util.Base64;
@@ -85,11 +86,10 @@ public final class HelpCommand implements BlazeCommand {
@Option(
name = "help_verbosity",
- category = "help",
defaultValue = "medium",
converter = Converters.HelpVerbosityConverter.class,
- documentationCategory = OptionDocumentationCategory.LOGGING,
- effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.TERMINAL_OUTPUT},
+ documentationCategory = OptionDocumentationCategory.LOGGING,
+ effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.TERMINAL_OUTPUT},
help = "Select the verbosity of the help command."
)
public OptionsParser.HelpVerbosity helpVerbosity;
@@ -98,10 +98,9 @@ public final class HelpCommand implements BlazeCommand {
name = "long",
abbrev = 'l',
defaultValue = "null",
- category = "help",
expansion = {"--help_verbosity=long"},
- documentationCategory = OptionDocumentationCategory.LOGGING,
- effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.TERMINAL_OUTPUT},
+ documentationCategory = OptionDocumentationCategory.LOGGING,
+ effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.TERMINAL_OUTPUT},
help = "Show full description of each option, instead of just its name."
)
public Void showLongFormOptions;
@@ -109,68 +108,12 @@ public final class HelpCommand implements BlazeCommand {
@Option(
name = "short",
defaultValue = "null",
- category = "help",
expansion = {"--help_verbosity=short"},
- documentationCategory = OptionDocumentationCategory.LOGGING,
- effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.TERMINAL_OUTPUT},
- help = "Show only the names of the options, not their types or meanings."
- )
- public Void showShortFormOptions;
-
- @Option(
- name = "use_new_category_enum",
- defaultValue = "true",
documentationCategory = OptionDocumentationCategory.LOGGING,
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.TERMINAL_OUTPUT},
- metadataTags = {OptionMetadataTag.EXPERIMENTAL}
+ help = "Show only the names of the options, not their types or meanings."
)
- public boolean useNewCategoryEnum;
- }
-
- /**
- * Returns a map that maps option categories to descriptive help strings for categories that are
- * not part of the Bazel core.
- */
- @Deprecated
- private static ImmutableMap<String, String> getDeprecatedOptionCategoriesDescriptions(
- String name) {
- ImmutableMap.Builder<String, String> optionCategoriesBuilder = ImmutableMap.builder();
- optionCategoriesBuilder
- .put("checking", String.format(
- "Checking options, which control %s's error checking and/or warnings", name))
- .put("coverage", String.format(
- "Options that affect how %s generates code coverage information", name))
- .put("experimental",
- "Experimental options, which control experimental (and potentially risky) features")
- .put("flags",
- "Flags options, for passing options to other tools")
- .put("help",
- "Help options")
- .put("host jvm startup", String.format(
- "Options that affect the startup of the %s server's JVM", name))
- .put("misc",
- "Miscellaneous options")
- .put("package loading",
- "Options that specify how to locate packages")
- .put("query", String.format(
- "Options affecting the '%s query' dependency query command", name))
- .put("run", String.format(
- "Options specific to '%s run'", name))
- .put("semantics",
- "Semantics options, which affect the build commands and/or output file contents")
- .put("server startup", String.format(
- "Startup options, which affect the startup of the %s server", name))
- .put("strategy", String.format(
- "Strategy options, which affect how %s will execute the build", name))
- .put("testing", String.format(
- "Options that affect how %s runs tests", name))
- .put("verbosity", String.format(
- "Verbosity options, which control what %s prints", name))
- .put("version",
- "Version options, for selecting which version of other tools will be used")
- .put("what",
- "Output selection options, for determining what to build/test");
- return optionCategoriesBuilder.build();
+ public Void showShortFormOptions;
}
@Override
@@ -198,20 +141,11 @@ public final class HelpCommand implements BlazeCommand {
switch (helpSubject) {
case "startup_options":
emitBlazeVersionInfo(outErr, runtime.getProductName());
- emitStartupOptions(
- outErr,
- helpOptions.helpVerbosity,
- runtime,
- getDeprecatedOptionCategoriesDescriptions(productName),
- helpOptions.useNewCategoryEnum);
+ emitStartupOptions(outErr, helpOptions.helpVerbosity, runtime);
return BlazeCommandResult.exitCode(ExitCode.SUCCESS);
case "target-syntax":
emitBlazeVersionInfo(outErr, runtime.getProductName());
- emitTargetSyntaxHelp(
- outErr,
- getDeprecatedOptionCategoriesDescriptions(productName),
- productName,
- helpOptions.useNewCategoryEnum);
+ emitTargetSyntaxHelp(outErr, productName);
return BlazeCommandResult.exitCode(ExitCode.SUCCESS);
case "info-keys":
@@ -224,7 +158,7 @@ public final class HelpCommand implements BlazeCommand {
emitFlagsAsProtoHelp(runtime, outErr);
return BlazeCommandResult.exitCode(ExitCode.SUCCESS);
case "everything-as-html":
- new HtmlEmitter(runtime, helpOptions.useNewCategoryEnum).emit(outErr);
+ new HtmlEmitter(runtime).emit(outErr);
return BlazeCommandResult.exitCode(ExitCode.SUCCESS);
default: // fall out
}
@@ -248,12 +182,10 @@ public final class HelpCommand implements BlazeCommand {
outErr.printOut(
BlazeCommandUtils.getUsage(
command.getClass(),
- getDeprecatedOptionCategoriesDescriptions(productName),
helpOptions.helpVerbosity,
runtime.getBlazeModules(),
runtime.getRuleClassProvider(),
- productName,
- helpOptions.useNewCategoryEnum));
+ productName));
return BlazeCommandResult.exitCode(ExitCode.SUCCESS);
}
@@ -265,21 +197,15 @@ public final class HelpCommand implements BlazeCommand {
}
private void emitStartupOptions(
- OutErr outErr,
- OptionsParser.HelpVerbosity helpVerbosity,
- BlazeRuntime runtime,
- ImmutableMap<String, String> optionCategories,
- boolean useNewCategoryEnum) {
+ OutErr outErr, HelpVerbosity helpVerbosity, BlazeRuntime runtime) {
outErr.printOut(
BlazeCommandUtils.expandHelpTopic(
"startup_options",
"resource:startup_options.txt",
getClass(),
BlazeCommandUtils.getStartupOptions(runtime.getBlazeModules()),
- optionCategories,
helpVerbosity,
- runtime.getProductName(),
- useNewCategoryEnum));
+ runtime.getProductName()));
}
private void emitCompletionHelp(BlazeRuntime runtime, OutErr outErr) {
@@ -380,21 +306,15 @@ public final class HelpCommand implements BlazeCommand {
return ImmutableSortedMap.copyOf(runtime.getCommandMap());
}
- private void emitTargetSyntaxHelp(
- OutErr outErr,
- ImmutableMap<String, String> optionCategories,
- String productName,
- boolean useNewCategoryEnum) {
+ private void emitTargetSyntaxHelp(OutErr outErr, String productName) {
outErr.printOut(
BlazeCommandUtils.expandHelpTopic(
"target-syntax",
"resource:target-syntax.txt",
getClass(),
ImmutableList.<Class<? extends OptionsBase>>of(),
- optionCategories,
OptionsParser.HelpVerbosity.MEDIUM,
- productName,
- useNewCategoryEnum));
+ productName));
}
private void emitInfoKeysHelp(CommandEnvironment env, OutErr outErr) {
@@ -441,19 +361,9 @@ public final class HelpCommand implements BlazeCommand {
private static final class HtmlEmitter {
private final BlazeRuntime runtime;
- private final ImmutableMap<String, String> deprecatedOptionCategoryDescriptions;
- private final boolean useNewCategoriesEnum;
- private HtmlEmitter(BlazeRuntime runtime, boolean useNewCategoriesEnum) {
+ private HtmlEmitter(BlazeRuntime runtime) {
this.runtime = runtime;
- this.useNewCategoriesEnum = useNewCategoriesEnum;
- String productName = runtime.getProductName();
- if (useNewCategoriesEnum) {
- this.deprecatedOptionCategoryDescriptions = null;
- } else {
- this.deprecatedOptionCategoryDescriptions =
- getDeprecatedOptionCategoriesDescriptions(productName);
- }
}
private void emit(OutErr outErr) {
@@ -529,7 +439,6 @@ public final class HelpCommand implements BlazeCommand {
}
// Describe the tags once, any mentions above should link to these descriptions.
- if (useNewCategoriesEnum) {
String productName = runtime.getProductName();
ImmutableMap<OptionEffectTag, String> effectTagDescriptions =
OptionFilterDescriptions.getOptionEffectTagDescription(productName);
@@ -567,7 +476,7 @@ public final class HelpCommand implements BlazeCommand {
}
}
result.append("</table>\n");
- }
+
outErr.printOut(result.toString());
}
@@ -576,18 +485,10 @@ public final class HelpCommand implements BlazeCommand {
StringBuilder result, Iterable<Class<? extends OptionsBase>> optionsClasses) {
OptionsParser parser = OptionsParser.newOptionsParser(optionsClasses);
String productName = runtime.getProductName();
- if (useNewCategoriesEnum) {
result.append(
parser
.describeOptionsHtml(HTML_ESCAPER, productName)
.replace("%{product}", productName));
- } else {
- result.append(
- parser
- .describeOptionsHtmlWithDeprecatedCategories(
- deprecatedOptionCategoryDescriptions, HTML_ESCAPER)
- .replace("%{product}", productName));
- }
}
private static String capitalize(String s) {