Top Description Inners Fields Constructors Methods
io.vertx.core.impl.launcher

public Class VertxCommandLauncher

extends UsageMessageFormatter
Class Inheritance
Known Direct Subclasses
io.vertx.core.Launcher
Imports
io.vertx.core.cli.*, io.vertx.core.cli.annotations.CLIConfigurator, io.vertx.core.impl.launcher.commands.RunCommand, io.vertx.core.spi.launcher.*, java.io.IOException, .InputStream, .PrintStream, java.net.URL, java.util.*, java.util.function.Supplier, java.util.jar.Attributes, .Manifest, java.util.stream.Collectors

The entry point of the Vert.x Command Line interface.
Author
Clement Escoffier

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
VertxCommandLauncher.CommandRegistration

Handles a command registration.

Field Summary

Modifier and TypeField and Description
protected final Map<String, VertxCommandLauncher.CommandRegistration>
commandByName

the list of commands.

protected final List<CommandFactoryLookup>
lookups

the list of lookups.

protected Object
main

the Main-Class object.

protected static List<String>
Inherited from io.vertx.core.cli.UsageMessageFormatter:
DEFAULT_ARG_NAMEDEFAULT_DESC_PADDEFAULT_LEFT_PADDEFAULT_LONG_OPT_PREFIXDEFAULT_LONG_OPT_SEPARATORDEFAULT_OPT_PREFIXDEFAULT_USAGE_PREFIXDEFAULT_WIDTHoptionComparator

Constructor Summary

AccessConstructor and Description
public
public
VertxCommandLauncher(Collection<CommandFactoryLookup>
the list of lookup
lookups
)

Creates a new VertxCommandLauncher using the given list of CommandFactoryLookup.

Method Summary

Modifier and TypeMethod and Description
public void
dispatch(String[]
the command line arguments.
args
)

Dispatches to the right command.

public void
dispatch(Object
the main instance on which hooks and callbacks are going to be called. If not set, the current object is used.
main
,
String[]
the command line arguments.
args
)

Dispatches to the right command.

public void
execute(String
the command name
command
,
String...
the arguments
cla
)

Executes the given command.

protected String
protected String
public Collection<String>

Returns:

the list of command.
getCommandNames
()

protected String

Returns:

the default command if specified in the MANIFEST, "run" if not found.
getDefaultCommand
()

public Command

Returns:

the Command instance, null if not found
getExistingCommandInstance
(String
the command name
name
)

Gets an existing instance of command.

private String
protected String

Returns:

the main verticle, null if not found.
getMainVerticle
()

protected Command

Returns:

the new instance, null if the command cannot be found.
getNewCommandInstance
(String
the command name
name
,
CommandLine
the command line
commandLine
)

Creates a new Command instance.

public PrintStream

Returns:

the printer used to write the messages. Defaults to System#out.
getPrintStream
()

public static List<String>

Returns:

the process argument. Verticles can use this method to retrieve the arguments.
getProcessArguments
()

protected static boolean
protected static boolean
protected void
load()

Loads the command.

protected void
protected void
protected void
protected void
protected void
public VertxCommandLauncher
register(CommandFactory<C extends Command> factory)

public VertxCommandLauncher
register(Class<? extends Command> clazz)
Deprecated

public VertxCommandLauncher
register(Class<? extends Command> clazz, Supplier<? extends Command> supplier)

public static void
resetProcessArguments()

For testing purpose only - reset the process arguments

public VertxCommandLauncher
Inherited from io.vertx.core.cli.UsageMessageFormatter:
appendArgumentappendOptionbuildWrappedbuildWrappedcomputeOptionsAndArgumentscomputeUsagecomputeUsageLinecreatePaddingfindWrapPosgetArgNamegetDescPaddinggetLeftPaddinggetLongOptionPrefixgetLongOptionSeparatorgetNewLinegetOptionComparatorgetOptionPrefixgetUsagePrefixgetWidthisNullOrEmptyrenderCommandsrenderOptionsAndArgumentsrenderWrappedTextrenderWrappedTextBlockrtrimsetArgNamesetDescPaddingsetLeftPaddingsetLongOptionPrefixsetLongOptionSeparatorsetNewLinesetOptionComparatorsetOptionPrefixsetUsagePrefixsetWidthusageusage

Field Detail

commandByNameback to summary
protected final Map<String, VertxCommandLauncher.CommandRegistration> commandByName

the list of commands. Sub-classes can decide to remove commands by removing entries from this map.

lookupsback to summary
protected final List<CommandFactoryLookup> lookups

the list of lookups.

mainback to summary
protected Object main

the Main-Class object.

PROCESS_ARGSback to summary
protected static List<String> PROCESS_ARGS

Constructor Detail

VertxCommandLauncherback to summary
public VertxCommandLauncher()

Creates a new VertxCommandLauncher using the default ServiceCommandFactoryLoader. It uses the classloader having loaded ServiceCommandFactoryLoader.

VertxCommandLauncherback to summary
public VertxCommandLauncher(Collection<CommandFactoryLookup> lookups)

Creates a new VertxCommandLauncher using the given list of CommandFactoryLookup.

Parameters
lookups:Collection<CommandFactoryLookup>

the list of lookup

Method Detail

dispatchback to summary
public void dispatch(String[] args)

Dispatches to the right command. This method is generally called from the main method.

Parameters
args:String[]

the command line arguments.

dispatchback to summary
public void dispatch(Object main, String[] args)

Dispatches to the right command. This method is generally called from the main method.

Parameters
main:Object

the main instance on which hooks and callbacks are going to be called. If not set, the current object is used.

args:String[]

the command line arguments.

executeback to summary
public void execute(String command, String... cla)

Executes the given command.

Parameters
command:String

the command name

cla:String[]

the arguments

getCommandFromManifestback to summary
protected String getCommandFromManifest()
getCommandLinePrefixback to summary
protected String getCommandLinePrefix()
getCommandNamesback to summary
public Collection<String> getCommandNames()
Returns:Collection<String>

the list of command.

getDefaultCommandback to summary
protected String getDefaultCommand()
Returns:String

the default command if specified in the MANIFEST, "run" if not found.

getExistingCommandInstanceback to summary
public Command getExistingCommandInstance(String name)

Gets an existing instance of command.

Parameters
name:String

the command name

Returns:Command

the Command instance, null if not found

getFromManifestback to summary
private String getFromManifest(String key)
getMainVerticleback to summary
protected String getMainVerticle()
Returns:String

the main verticle, null if not found.

getNewCommandInstanceback to summary
protected Command getNewCommandInstance(String name, CommandLine commandLine)

Creates a new Command instance. Sub-classes can change how Command instance are created.

Parameters
name:String

the command name

commandLine:CommandLine

the command line

Returns:Command

the new instance, null if the command cannot be found.

getPrintStreamback to summary
public PrintStream getPrintStream()
Returns:PrintStream

the printer used to write the messages. Defaults to System#out.

getProcessArgumentsback to summary
public static List<String> getProcessArguments()
Returns:List<String>

the process argument. Verticles can use this method to retrieve the arguments.

isAskingForHelpback to summary
protected static boolean isAskingForHelp(String command)
isAskingForVersionback to summary
protected static boolean isAskingForVersion(String command)
loadback to summary
protected void load()

Loads the command. This method is protected to let sub-classes change the set of command or how they are loaded.

printCommandNotFoundback to summary
protected void printCommandNotFound(String command)
printCommandUsageback to summary
protected void printCommandUsage(CLI cli)
printGenericExecutionErrorback to summary
protected void printGenericExecutionError(CLI cli, CLIException e)
printGlobalUsageback to summary
protected void printGlobalUsage()
printSpecificExceptionback to summary
protected void printSpecificException(CLI cli, Exception e)
registerback to summary
public VertxCommandLauncher register(CommandFactory<C extends Command> factory)
registerback to summary
public VertxCommandLauncher register(Class<? extends Command> clazz)

Deprecated

Annotations
@Deprecated
@SuppressWarnings:unchecked
registerback to summary
public VertxCommandLauncher register(Class<? extends Command> clazz, Supplier<? extends Command> supplier)
Annotations
@SuppressWarnings:unchecked
resetProcessArgumentsback to summary
public static void resetProcessArguments()

For testing purpose only - reset the process arguments

unregisterback to summary
public VertxCommandLauncher unregister(String name)
io.vertx.core.impl.launcher back to summary

public Class VertxCommandLauncher.CommandRegistration

extends Object
Class Inheritance
  • java.lang.Object
  • io.vertx.core.impl.launcher.VertxCommandLauncher.CommandRegistration

Handles a command registration.

Field Summary

Modifier and TypeField and Description
public final CLI
private List<Command>
public final CommandFactory<C extends Command>

Constructor Summary

AccessConstructor and Description
public
public
CommandRegistration(CommandFactory<C extends Command> factory, CLI cli)

Method Summary

Modifier and TypeMethod and Description
public void
public Command
public List<Command>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cliback to summary
public final CLI cli
commandsback to summary
private List<Command> commands
factoryback to summary
public final CommandFactory<C extends Command> factory

Constructor Detail

CommandRegistrationback to summary
public CommandRegistration(CommandFactory<C extends Command> factory)
CommandRegistrationback to summary
public CommandRegistration(CommandFactory<C extends Command> factory, CLI cli)

Method Detail

addCommandback to summary
public void addCommand(Command command)
getCommandback to summary
public Command getCommand()
getCommandsback to summary
public List<Command> getCommands()