use of com.google.devtools.build.lib.runtime.Command in project bazel by bazelbuild.
the class HelpCommand method emitCompletionHelp.
private void emitCompletionHelp(BlazeRuntime runtime, OutErr outErr) {
// First startup_options
Iterable<BlazeModule> blazeModules = runtime.getBlazeModules();
ConfiguredRuleClassProvider ruleClassProvider = runtime.getRuleClassProvider();
Map<String, BlazeCommand> commandsByName = getSortedCommands(runtime);
outErr.printOutLn("BAZEL_COMMAND_LIST=\"" + SPACE_JOINER.join(commandsByName.keySet()) + "\"");
outErr.printOutLn("BAZEL_INFO_KEYS=\"");
for (String name : InfoCommand.getHardwiredInfoItemNames(runtime.getProductName())) {
outErr.printOutLn(name);
}
outErr.printOutLn("\"");
outErr.printOutLn("BAZEL_STARTUP_OPTIONS=\"");
Iterable<Class<? extends OptionsBase>> options = BlazeCommandUtils.getStartupOptions(blazeModules);
outErr.printOut(OptionsParser.newOptionsParser(options).getOptionsCompletion());
outErr.printOutLn("\"");
for (Map.Entry<String, BlazeCommand> e : commandsByName.entrySet()) {
BlazeCommand command = e.getValue();
String varName = e.getKey().toUpperCase(Locale.US).replace('-', '_');
Command annotation = command.getClass().getAnnotation(Command.class);
if (!annotation.completion().isEmpty()) {
outErr.printOutLn("BAZEL_COMMAND_" + varName + "_ARGUMENT=\"" + annotation.completion() + "\"");
}
options = BlazeCommandUtils.getOptions(command.getClass(), blazeModules, ruleClassProvider);
outErr.printOutLn("BAZEL_COMMAND_" + varName + "_FLAGS=\"");
outErr.printOut(OptionsParser.newOptionsParser(options).getOptionsCompletion());
outErr.printOutLn("\"");
}
}
use of com.google.devtools.build.lib.runtime.Command in project bazel by bazelbuild.
the class HelpCommand method emitGenericHelp.
private void emitGenericHelp(OutErr outErr, BlazeRuntime runtime) {
outErr.printOut(String.format("Usage: %s <command> <options> ...\n\n", runtime.getProductName()));
outErr.printOut("Available commands:\n");
Map<String, BlazeCommand> commandsByName = runtime.getCommandMap();
List<String> namesInOrder = new ArrayList<>(commandsByName.keySet());
Collections.sort(namesInOrder);
for (String name : namesInOrder) {
BlazeCommand command = commandsByName.get(name);
Command annotation = command.getClass().getAnnotation(Command.class);
if (annotation.hidden()) {
continue;
}
String shortDescription = annotation.shortDescription().replace("%{product}", runtime.getProductName());
outErr.printOut(String.format(" %-19s %s\n", name, shortDescription));
}
outErr.printOut("\n");
outErr.printOut("Getting more help:\n");
outErr.printOut(String.format(" %s help <command>\n", runtime.getProductName()));
outErr.printOut(" Prints help and options for <command>.\n");
outErr.printOut(String.format(" %s help startup_options\n", runtime.getProductName()));
outErr.printOut(String.format(" Options for the JVM hosting %s.\n", runtime.getProductName()));
outErr.printOut(String.format(" %s help target-syntax\n", runtime.getProductName()));
outErr.printOut(" Explains the syntax for specifying targets.\n");
outErr.printOut(String.format(" %s help info-keys\n", runtime.getProductName()));
outErr.printOut(" Displays a list of keys used by the info command.\n");
}
Aggregations