A
- the type parameter defining the arguments and options of the
commandpublic interface Command<A extends Arguments<A>>
name
and the command line arguments
.
To execute a command, execute(ExecutionContext, LineProcessor)
is
called which returns a LineProcessor
object to perform the
line-by-line command execution.
Commands can be joined
to other commands which usually
means that the first command's output forms the input of the second command.
Modifier and Type | Method and Description |
---|---|
LineProcessor |
execute(ExecutionContext context,
LineProcessor output)
Executes this command and returns a
LineProcessor object. |
A |
getArguments(ExecutionContext context)
Returns the implementation specific command arguments and options for the
given execution context.
|
String |
getName()
Returns the name of this command, usually a lower-case string such as
"grep" or "ls".
|
Command<?> |
join(Command<?> next)
Returns a new command representing the combination of
this
command with next . |
String |
toString()
Returns a string representation of the command instance including the
argument and option values defined for the command.
|
String getName()
A getArguments(ExecutionContext context)
VariableContext
returned by the given context
object. No variables are resolved if context
is null.context
- the execution context with access to variables and value
converters, or null if no variables should be resolvedArguments.getForContext(ExecutionContext)
Command<?> join(Command<?> next)
this
command with next
. The returned command executes this
command first and usually joins the output to the next
command's
input.
Note that some commands may use a slightly different interpretation of
"joining a command". The xargs
command for instance uses its
joined command as target command; the values collected by xargs
on its input stream are passed to the target command as arguments instead
of as input.
next
- the next command to join to this commandthis
command joined to next
LineProcessor execute(ExecutionContext context, LineProcessor output)
LineProcessor
object. Calling
this method initiates the command execution, but the real processing of
the command takes place when lines are passed to the returned
LineProcessor
object. The command execution is terminated by
calling LineProcessor.finish()
.
The command writes its output to the specified output
object.
Depending on the command implementation, the output is written when lines
are passed to the LineProcessor
returned by this method, or when
the execution terminates with the finish()
call.
context
- context object providing access to the current directory,
environment variables and other information useful for the
command during its executionoutput
- the output to write toCopyright © 2024. All rights reserved.