if ( showErrors )
{
System.out.println( "+ Error stacktraces are turned on." );
}
Converter converter = new DefaultConverter();
Log log = new SystemStreamLog();
if ( debug )
{
log.setLogLevel( Log.LEVEL_DEBUG );
}
converter.enableLogging( log );
InputFileWrapper input;
OutputFileWrapper output;
try
{
input =
InputFileWrapper.valueOf( commandLine.getOptionValue( CLIManager.IN ),
commandLine.getOptionValue( CLIManager.FROM ),
commandLine.getOptionValue( CLIManager.INENCODING ),
converter.getInputFormats() );
output =
OutputFileWrapper.valueOf( commandLine.getOptionValue( CLIManager.OUT ),
commandLine.getOptionValue( CLIManager.TO ),
commandLine.getOptionValue( CLIManager.OUTENCODING ),
converter.getOutputFormats() );
}
catch ( IllegalArgumentException e )
{
showFatalError( "Illegal argument: " + e.getMessage(), e, showErrors );
CLIManager.displayHelp();
return 1;
}
catch ( UnsupportedEncodingException e )
{
showFatalError( e.getMessage(), e, showErrors );
return 1;
}
catch ( FileNotFoundException e )
{
showFatalError( e.getMessage(), e, showErrors );
return 1;
}
boolean format = commandLine.hasOption( CLIManager.FORMAT );
converter.setFormatOutput( format );
try
{
converter.convert( input, output );
}
catch ( UnsupportedFormatException e )
{
showFatalError( e.getMessage(), e, showErrors );