public class VertxCommandLauncher extends UsageMessageFormatter
| Modifier and Type | Class and Description |
|---|---|
static class |
VertxCommandLauncher.CommandRegistration
Handles a command registration.
|
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,VertxCommandLauncher.CommandRegistration> |
commandByName
the list of commands.
|
protected List<CommandFactoryLookup> |
lookups
the list of lookups.
|
protected Object |
main
the
Main-Class object. |
protected static List<String> |
PROCESS_ARGS |
DEFAULT_ARG_NAME, DEFAULT_DESC_PAD, DEFAULT_LEFT_PAD, DEFAULT_LONG_OPT_PREFIX, DEFAULT_LONG_OPT_SEPARATOR, DEFAULT_OPT_PREFIX, DEFAULT_USAGE_PREFIX, DEFAULT_WIDTH, optionComparator| Constructor and Description |
|---|
VertxCommandLauncher()
Creates a new
VertxCommandLauncher using the default ServiceCommandFactoryLoader. |
VertxCommandLauncher(Collection<CommandFactoryLookup> lookups)
Creates a new
VertxCommandLauncher using the given list of CommandFactoryLookup. |
| Modifier and Type | Method and Description |
|---|---|
void |
dispatch(Object main,
String[] args)
Dispatches to the right command.
|
void |
dispatch(String[] args)
Dispatches to the right command.
|
void |
execute(String command,
String... cla)
Executes the given command.
|
protected String |
getCommandFromManifest() |
protected String |
getCommandLinePrefix() |
Collection<String> |
getCommandNames() |
protected String |
getDefaultCommand() |
Command |
getExistingCommandInstance(String name)
Gets an existing instance of command.
|
protected String |
getMainVerticle() |
protected Command |
getNewCommandInstance(String name,
CommandLine commandLine)
Creates a new
Command instance. |
PrintStream |
getPrintStream() |
static List<String> |
getProcessArguments() |
protected static boolean |
isAskingForHelp(String command) |
protected static boolean |
isAskingForVersion(String command) |
protected void |
load()
Loads the command.
|
protected void |
printCommandNotFound(String command) |
protected void |
printCommandUsage(CLI cli) |
protected void |
printGenericExecutionError(CLI cli,
CLIException e) |
protected void |
printGlobalUsage() |
protected void |
printSpecificException(CLI cli,
Exception e) |
VertxCommandLauncher |
register(Class<? extends Command> clazz)
Deprecated.
|
VertxCommandLauncher |
register(Class<? extends Command> clazz,
Supplier<? extends Command> supplier) |
VertxCommandLauncher |
register(CommandFactory factory) |
static void |
resetProcessArguments()
For testing purpose only - reset the process arguments
|
VertxCommandLauncher |
unregister(String name) |
appendArgument, appendOption, buildWrapped, buildWrapped, computeOptionsAndArguments, computeUsage, computeUsageLine, createPadding, findWrapPos, getArgName, getDescPadding, getLeftPadding, getLongOptionPrefix, getLongOptionSeparator, getNewLine, getOptionComparator, getOptionPrefix, getUsagePrefix, getWidth, isNullOrEmpty, renderCommands, renderOptionsAndArguments, renderWrappedText, renderWrappedTextBlock, rtrim, setArgName, setDescPadding, setLeftPadding, setLongOptionPrefix, setLongOptionSeparator, setNewLine, setOptionComparator, setOptionPrefix, setUsagePrefix, setWidth, usage, usageprotected final List<CommandFactoryLookup> lookups
protected final Map<String,VertxCommandLauncher.CommandRegistration> commandByName
protected Object main
Main-Class object.public VertxCommandLauncher()
VertxCommandLauncher using the default ServiceCommandFactoryLoader. It uses the
classloader having loaded ServiceCommandFactoryLoader.public VertxCommandLauncher(Collection<CommandFactoryLookup> lookups)
VertxCommandLauncher using the given list of CommandFactoryLookup.lookups - the list of lookuppublic static List<String> getProcessArguments()
protected void load()
protected to let sub-classes change the set of command or how
they are loaded.public VertxCommandLauncher register(CommandFactory factory)
@Deprecated public VertxCommandLauncher register(Class<? extends Command> clazz)
public VertxCommandLauncher register(Class<? extends Command> clazz, Supplier<? extends Command> supplier)
public VertxCommandLauncher unregister(String name)
public Collection<String> getCommandNames()
protected Command getNewCommandInstance(String name, CommandLine commandLine)
name - the command namecommandLine - the command linenull if the command cannot be found.public Command getExistingCommandInstance(String name)
name - the command nameCommand instance, null if not foundpublic void execute(String command, String... cla)
command - the command namecla - the argumentsprotected void printCommandUsage(CLI cli)
protected void printGenericExecutionError(CLI cli, CLIException e)
protected void printCommandNotFound(String command)
protected void printGlobalUsage()
protected String getCommandLinePrefix()
protected static boolean isAskingForHelp(String command)
protected static boolean isAskingForVersion(String command)
public void dispatch(String[] args)
main method.args - the command line arguments.public void dispatch(Object main, String[] args)
main method.main - the main instance on which hooks and callbacks are going to be called. If not set, the current
object is used.args - the command line arguments.protected String getDefaultCommand()
MANIFEST, "run" if not found.protected String getCommandFromManifest()
public PrintStream getPrintStream()
System.out.protected String getMainVerticle()
null if not found.public static void resetProcessArguments()
Copyright © 2020. All rights reserved.