public class TerminalInvoker extends Object
main
method, using a command line interface.
The Task invoke methods are invoked and may throw any exception;
UsageException
and ExecutionException
will be treated
specially (a sanitised error message without stacktrace will be
presented to the user).Constructor and Description |
---|
TerminalInvoker(String toolname,
Map<String,Task> taskmap)
Creates a new invoker based on the given class with a given name.
|
Modifier and Type | Method and Description |
---|---|
static String |
getTaskUsage(Task task)
Returns a usage string for a given task.
|
void |
invoke(String[] args)
Invokes a method from this TerminalInvoker's class.
|
public TerminalInvoker(String toolname, Map<String,Task> taskmap)
System.exit
rather than
returning.toolname
- the name of this tool, used for user messagestaskmap
- map of task names to Task
objectspublic void invoke(String[] args) throws Exception
args
identifies the method to be
called - it is a case-insensitive version of the name of a method
in the class. Subsequent elements are passed
(as an args.length-1
element array of Strings)
to the method in question.
In the event of any trouble (e.g. unknown task, task method throws
an exception) a message is printed to standard error and
the JVM exits.args
- the arguments identifying what method to call and what
arguments to pass to itException
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.