}
}
public static void main(final String[] args)
{
Command command = null;
try
{
// initialize java.protocol.handler.pkgs
initProtocolHandlers();
// Prosess global options
processArguments(args);
loadCommands();
// Now execute the command
if (commandName == null)
{
// Display program help
displayHelp();
}
else
{
command = twiddle.createCommand(commandName);
if (commandHelp)
{
System.out.println("Help for command: '" + command.getName() + "'");
System.out.println();
command.displayHelp();
}
else
{
// Execute the command
command.execute(commandArgs);
}
}
System.exit(0);
}
catch (CommandException e)
{
log.error("Command failure", e);
System.err.println();
if (e instanceof NoSuchCommandException)
{
twiddle.displayCommandList();
}
else
{
if (command != null)
{
System.err.println("Help for command: '" + command.getName() + "'");
System.err.println();
command.displayHelp();
}
}
System.exit(1);
}
catch (Exception e)