2008-02-13 15:08:06 -05:00
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
2007-12-23 14:28:04 -05:00
|
|
|
import javax.swing.SwingUtilities;
|
|
|
|
import javax.swing.UIManager;
|
|
|
|
|
2008-07-30 18:37:01 -04:00
|
|
|
import net.sourceforge.filebot.ArgumentBean;
|
2008-03-19 18:14:38 -04:00
|
|
|
import net.sourceforge.filebot.Settings;
|
2007-12-23 14:28:04 -05:00
|
|
|
import net.sourceforge.filebot.ui.FileBotWindow;
|
2008-07-30 18:37:01 -04:00
|
|
|
|
|
|
|
import org.kohsuke.args4j.CmdLineException;
|
|
|
|
import org.kohsuke.args4j.CmdLineParser;
|
2007-12-23 14:28:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
public class Main {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param args
|
|
|
|
*/
|
2008-06-21 15:24:18 -04:00
|
|
|
public static void main(String... args) {
|
2008-02-13 15:08:06 -05:00
|
|
|
|
2008-07-30 18:37:01 -04:00
|
|
|
final ArgumentBean argumentBean = parseArguments(args);
|
2008-03-19 18:14:38 -04:00
|
|
|
|
2008-07-30 18:37:01 -04:00
|
|
|
if (argumentBean.isClear())
|
2008-03-19 18:14:38 -04:00
|
|
|
Settings.getSettings().clear();
|
|
|
|
|
2007-12-23 14:28:04 -05:00
|
|
|
try {
|
|
|
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
|
|
|
} catch (Exception e) {
|
2008-03-15 21:05:06 -04:00
|
|
|
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.toString(), e);
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
SwingUtilities.invokeLater(new Runnable() {
|
|
|
|
|
2008-03-19 18:14:38 -04:00
|
|
|
@Override
|
2007-12-23 14:28:04 -05:00
|
|
|
public void run() {
|
2008-06-21 15:24:18 -04:00
|
|
|
FileBotWindow window = new FileBotWindow();
|
|
|
|
|
|
|
|
// publish messages from arguments to the newly created components
|
2008-07-30 18:37:01 -04:00
|
|
|
argumentBean.publishMessages();
|
2008-06-21 15:24:18 -04:00
|
|
|
|
|
|
|
// start
|
2008-03-19 18:14:38 -04:00
|
|
|
window.setVisible(true);
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2008-03-19 18:14:38 -04:00
|
|
|
|
2008-07-30 18:37:01 -04:00
|
|
|
|
|
|
|
private static ArgumentBean parseArguments(String... args) {
|
2008-03-19 18:14:38 -04:00
|
|
|
|
2008-07-30 18:37:01 -04:00
|
|
|
ArgumentBean argumentBean = new ArgumentBean();
|
|
|
|
CmdLineParser argumentParser = new CmdLineParser(argumentBean);
|
2008-03-19 18:14:38 -04:00
|
|
|
|
2008-07-30 18:37:01 -04:00
|
|
|
try {
|
|
|
|
argumentParser.parseArgument(args);
|
|
|
|
} catch (CmdLineException e) {
|
|
|
|
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, e.getMessage());
|
2008-03-19 18:14:38 -04:00
|
|
|
}
|
|
|
|
|
2008-07-30 18:37:01 -04:00
|
|
|
if (argumentBean.isHelp()) {
|
|
|
|
System.out.println("Options:");
|
|
|
|
argumentParser.printUsage(System.out);
|
|
|
|
|
|
|
|
// just print help message and exit afterwards
|
|
|
|
System.exit(0);
|
2008-03-19 18:14:38 -04:00
|
|
|
}
|
|
|
|
|
2008-07-30 18:37:01 -04:00
|
|
|
return argumentBean;
|
2008-03-19 18:14:38 -04:00
|
|
|
}
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|