public interface PluginBasedCommand
Implementations of this class will have logic to control common logic of a particular
plugin-based command. For example, buck project command will have an implementation that
implements this class and adds some common domain-independent logic to route a particular
invocation to some implementation loaded from plugins.
Typical example of usage:
class ExamplePluginBasedCommand extends PluginBasedCommand {
@PluginBasedSubCommands(factoryClass = ExamplePluginBasedSubCommandFactory.class)
@SuppressFieldNotInitialized
private ImmutableList modes;
@Override
protected ImmutableList extends PluginBasedSubCommand> getSubCommands() {
return modes;
}
@Override
protected String getTypeOptionName() {
return "--mode";
}
}
interface ExamplePluginBasedSubCommandFactory extends PluginBasedSubCommandFactory {
}
@Extention
class SomeExamplePluginBasedSubCommand implements ExamplePluginBasedSubCommandFactory {
@Override
SomeExamplePluginBasedSubCommand createSubCommand() {
return new SomeExamplePluginBasedSubCommand();
}
}
Key points:
PluginBasedSubCommandFactory.
PluginBasedSubCommand.
getTypeOptionName() is used to control which option is used to select a subcommand.
The logic in this class uses that method for help screen only. The particular
implementations need to use the option with that name to select a particular subcommand.
| Modifier and Type | Method and Description |
|---|---|
String |
getShortDescription() |
com.google.common.collect.ImmutableList<? extends PluginBasedSubCommand> |
getSubCommands() |
String |
getTypeOptionName() |
default void |
printUsage(PrintStream stream)
Prints the usage to the provided stream.
|
com.google.common.collect.ImmutableList<? extends PluginBasedSubCommand> getSubCommands()
String getTypeOptionName()
String getShortDescription()
default void printUsage(PrintStream stream)