OptionsConsoleCommandpublic abstract class OptionsConsoleCommand extends IConsoleCommand subclass of IConsoleCommand that allows the parameters to be defined using
an Options object |
Fields Summary |
---|
private org.apache.commons.cli.Options | options | private org.apache.commons.cli.CommandLineParser | parser |
Constructors Summary |
---|
public OptionsConsoleCommand(String[] commandNames)
super(commandNames);
|
Methods Summary |
---|
public void | execute(java.lang.String commandName, org.gudy.azureus2.ui.console.ConsoleInput console, java.util.List arguments)take the args and try and create a command line object
CommandLineParser parser = getParser();
try
{
String []args = new String[arguments.size()];
int i = 0;
for (Iterator iter = arguments.iterator(); iter.hasNext();) {
String arg = (String) iter.next();
args[i++] = arg;
}
CommandLine line = parser.parse(getOptions(), args);
execute( commandName, console, line );
} catch (ParseException e)
{
console.out.println(">> Invalid arguments: " + e.getMessage());
// printHelp(commandName, console.out);
printHelp(console.out, arguments);
}
| public abstract void | execute(java.lang.String commandName, org.gudy.azureus2.ui.console.ConsoleInput console, org.apache.commons.cli.CommandLine commandLine)execute using the specified command line.
| protected org.apache.commons.cli.Options | getOptions()
return options;
| protected org.apache.commons.cli.CommandLineParser | getParser()
if( parser == null )
parser = new PosixParser();
return parser;
| public void | printHelp(java.io.PrintStream out, java.util.List args)
HelpFormatter formatter = new HelpFormatter();
PrintWriter writer = new PrintWriter(out);
writer.println("> -----");
writer.println(getCommandDescriptions());
// formatter.printHelp(writer, 80, getCommandDescriptions(), ">>>", getOptions(), 4, 4, ">>>", true);
formatter.printOptions(writer, 80, getOptions(), 4, 4);
writer.println("> -----");
writer.flush();
|
|