Remove GUI code.
[jSite.git] / src / de / todesbaum / jsite / main / Main.java
1 /*
2  * jSite - a tool for uploading websites into Freenet
3  * Copyright (C) 2006 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package de.todesbaum.jsite.main;
21
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import java.io.File;
25 import java.io.IOException;
26 import java.text.MessageFormat;
27 import java.util.HashMap;
28 import java.util.Locale;
29 import java.util.Map;
30 import java.util.Set;
31 import java.util.Map.Entry;
32
33 import javax.swing.AbstractAction;
34 import javax.swing.Action;
35 import javax.swing.ButtonGroup;
36 import javax.swing.Icon;
37 import javax.swing.JList;
38 import javax.swing.JMenu;
39 import javax.swing.JMenuBar;
40 import javax.swing.JOptionPane;
41 import javax.swing.JPanel;
42 import javax.swing.JRadioButtonMenuItem;
43 import javax.swing.event.ListSelectionEvent;
44 import javax.swing.event.ListSelectionListener;
45
46 import de.todesbaum.jsite.application.FileOption;
47 import de.todesbaum.jsite.application.Freenet7Interface;
48 import de.todesbaum.jsite.application.Node;
49 import de.todesbaum.jsite.application.Project;
50 import de.todesbaum.jsite.gui.NodeManagerListener;
51 import de.todesbaum.jsite.gui.NodeManagerPage;
52 import de.todesbaum.jsite.gui.ProjectFilesPage;
53 import de.todesbaum.jsite.gui.ProjectInsertPage;
54 import de.todesbaum.jsite.gui.ProjectPage;
55 import de.todesbaum.jsite.gui.UpdateChecker;
56 import de.todesbaum.jsite.i18n.I18n;
57 import de.todesbaum.jsite.i18n.I18nContainer;
58 import de.todesbaum.util.image.IconLoader;
59 import de.todesbaum.util.swing.TWizard;
60 import de.todesbaum.util.swing.TWizardPage;
61 import de.todesbaum.util.swing.WizardListener;
62
63 /**
64  * The main class that ties together everything.
65  *
66  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
67  */
68 public class Main implements ActionListener, ListSelectionListener, WizardListener, NodeManagerListener {
69
70         /** Whether the debug mode is activated. */
71         private static boolean debug = false;
72
73         /** The version. */
74         private static final Version VERSION = new Version(0, 6, 2);
75
76         /** The configuration. */
77         private Configuration configuration;
78
79         /** The freenet interface. */
80         private Freenet7Interface freenetInterface = new Freenet7Interface();
81
82         /** The update checker. */
83         private final UpdateChecker updateChecker;
84
85         /** The jSite icon. */
86         private Icon jSiteIcon;
87
88         /**
89          * Enumeration for all possible pages.
90          *
91          * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
92          */
93         private static enum PageType {
94
95                 /** The node manager page. */
96                 PAGE_NODE_MANAGER,
97
98                 /** The project page. */
99                 PAGE_PROJECTS,
100
101                 /** The project files page. */
102                 PAGE_PROJECT_FILES,
103
104                 /** The project insert page. */
105                 PAGE_INSERT_PROJECT
106
107         }
108
109         /** The supported locales. */
110         private static final Locale[] SUPPORTED_LOCALES = new Locale[] { Locale.ENGLISH, Locale.GERMAN, Locale.FRENCH, Locale.ITALIAN, new Locale("pl") };
111
112         /** The actions that switch the language. */
113         private Map<Locale, Action> languageActions = new HashMap<Locale, Action>();
114
115         /** The “manage nodes” action. */
116         private Action manageNodeAction;
117
118         /** The “check for updates” action. */
119         private Action checkForUpdatesAction;
120
121         /** The “about jSite” action. */
122         private Action aboutAction;
123
124         /** The wizard. */
125         private TWizard wizard;
126
127         /** The node menu. */
128         private JMenu nodeMenu;
129
130         /** The currently selected node. */
131         private Node selectedNode;
132
133         /** Mapping from page type to page. */
134         private final Map<PageType, TWizardPage> pages = new HashMap<PageType, TWizardPage>();
135
136         /**
137          * Creates a new core with the default configuration file.
138          */
139         private Main() {
140                 this(null);
141         }
142
143         /**
144          * Creates a new core with the given configuration from the given file.
145          *
146          * @param configFilename
147          *            The name of the configuration file
148          */
149         private Main(String configFilename) {
150                 if (configFilename != null) {
151                         configuration = new Configuration(configFilename);
152                 } else {
153                         configuration = new Configuration();
154                 }
155                 Locale.setDefault(configuration.getLocale());
156                 I18n.setLocale(configuration.getLocale());
157                 if (!configuration.createLockFile()) {
158                         int option = JOptionPane.showOptionDialog(null, I18n.getMessage("jsite.main.already-running"), "", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { I18n.getMessage("jsite.main.already-running.override"), I18n.getMessage("jsite.wizard.quit") }, I18n.getMessage("jsite.wizard.quit"));
159                         if (option != 0) {
160                                 throw new IllegalStateException("Lockfile override not active, refusing start.");
161                         }
162                         configuration.removeLockfileOnExit();
163                 }
164                 wizard = new TWizard();
165                 createActions();
166                 wizard.setJMenuBar(createMenuBar());
167                 wizard.setQuitName(I18n.getMessage("jsite.wizard.quit"));
168                 wizard.setPreviousEnabled(false);
169                 wizard.setNextEnabled(true);
170                 wizard.addWizardListener(this);
171                 jSiteIcon = IconLoader.loadIcon("/jsite-icon.png");
172                 wizard.setIcon(jSiteIcon);
173
174                 updateChecker = new UpdateChecker(wizard, freenetInterface);
175                 updateChecker.start();
176
177                 initPages();
178                 showPage(PageType.PAGE_PROJECTS);
179         }
180
181         /**
182          * Creates all actions.
183          */
184         private void createActions() {
185                 for (final Locale locale : SUPPORTED_LOCALES) {
186                         languageActions.put(locale, new AbstractAction(I18n.getMessage("jsite.menu.language." + locale.getLanguage()), IconLoader.loadIcon("/flag-" + locale.getLanguage() + ".png")) {
187
188                                 @SuppressWarnings("synthetic-access")
189                                 public void actionPerformed(ActionEvent actionEvent) {
190                                         switchLanguage(locale);
191                                 }
192                         });
193                 }
194                 manageNodeAction = new AbstractAction(I18n.getMessage("jsite.menu.nodes.manage-nodes")) {
195
196                         @SuppressWarnings("synthetic-access")
197                         public void actionPerformed(ActionEvent actionEvent) {
198                                 showPage(PageType.PAGE_NODE_MANAGER);
199                                 wizard.setPreviousName(I18n.getMessage("jsite.wizard.previous"));
200                                 wizard.setNextName(I18n.getMessage("jsite.wizard.next"));
201                         }
202                 };
203                 checkForUpdatesAction = new AbstractAction(I18n.getMessage("jsite.menu.help.check-for-updates")) {
204
205                         /**
206                          * {@inheritDoc}
207                          */
208                         public void actionPerformed(ActionEvent actionEvent) {
209                                 /* TODO */
210                         }
211                 };
212                 aboutAction = new AbstractAction(I18n.getMessage("jsite.menu.help.about")) {
213
214                         @SuppressWarnings("synthetic-access")
215                         public void actionPerformed(ActionEvent e) {
216                                 JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.about.message"), getVersion().toString()), null, JOptionPane.INFORMATION_MESSAGE, jSiteIcon);
217                         }
218                 };
219
220                 I18nContainer.getInstance().registerRunnable(new Runnable() {
221
222                         @SuppressWarnings("synthetic-access")
223                         public void run() {
224                                 manageNodeAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.nodes.manage-nodes"));
225                                 aboutAction.putValue(Action.NAME, I18n.getMessage("jsite.menu.help.about"));
226                         }
227                 });
228         }
229
230         /**
231          * Creates the menu bar.
232          *
233          * @return The menu bar
234          */
235         private JMenuBar createMenuBar() {
236                 JMenuBar menuBar = new JMenuBar();
237                 final JMenu languageMenu = new JMenu(I18n.getMessage("jsite.menu.languages"));
238                 menuBar.add(languageMenu);
239                 ButtonGroup languageButtonGroup = new ButtonGroup();
240                 for (Locale locale : SUPPORTED_LOCALES) {
241                         Action languageAction = languageActions.get(locale);
242                         JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(languageActions.get(locale));
243                         if (locale.equals(Locale.getDefault())) {
244                                 menuItem.setSelected(true);
245                         }
246                         languageAction.putValue("menuItem", menuItem);
247                         languageButtonGroup.add(menuItem);
248                         languageMenu.add(menuItem);
249                 }
250                 nodeMenu = new JMenu(I18n.getMessage("jsite.menu.nodes"));
251                 menuBar.add(nodeMenu);
252                 selectedNode = configuration.getSelectedNode();
253                 nodesUpdated(configuration.getNodes());
254
255                 /* evil hack to right-align the help menu */
256                 JPanel panel = new JPanel();
257                 panel.setOpaque(false);
258                 menuBar.add(panel);
259
260                 final JMenu helpMenu = new JMenu(I18n.getMessage("jsite.menu.help"));
261                 menuBar.add(helpMenu);
262                 helpMenu.add(checkForUpdatesAction);
263                 helpMenu.add(aboutAction);
264
265                 I18nContainer.getInstance().registerRunnable(new Runnable() {
266
267                         @SuppressWarnings("synthetic-access")
268                         public void run() {
269                                 languageMenu.setText(I18n.getMessage("jsite.menu.languages"));
270                                 nodeMenu.setText(I18n.getMessage("jsite.menu.nodes"));
271                                 helpMenu.setText(I18n.getMessage("jsite.menu.help"));
272                                 for (Map.Entry<Locale, Action> languageActionEntry : languageActions.entrySet()) {
273                                         languageActionEntry.getValue().putValue(Action.NAME, I18n.getMessage("jsite.menu.language." + languageActionEntry.getKey().getLanguage()));
274                                 }
275                         }
276                 });
277
278                 return menuBar;
279         }
280
281         /**
282          * Initializes all pages.
283          */
284         private void initPages() {
285                 NodeManagerPage nodeManagerPage = new NodeManagerPage(wizard);
286                 nodeManagerPage.setName("page.node-manager");
287                 nodeManagerPage.addNodeManagerListener(this);
288                 nodeManagerPage.setNodes(configuration.getNodes());
289                 pages.put(PageType.PAGE_NODE_MANAGER, nodeManagerPage);
290
291                 ProjectPage projectPage = new ProjectPage(wizard);
292                 projectPage.setName("page.project");
293                 projectPage.setProjects(configuration.getProjects());
294                 projectPage.setFreenetInterface(freenetInterface);
295                 projectPage.addListSelectionListener(this);
296                 pages.put(PageType.PAGE_PROJECTS, projectPage);
297
298                 ProjectFilesPage projectFilesPage = new ProjectFilesPage(wizard);
299                 projectFilesPage.setName("page.project.files");
300                 pages.put(PageType.PAGE_PROJECT_FILES, projectFilesPage);
301
302                 ProjectInsertPage projectInsertPage = new ProjectInsertPage(wizard);
303                 projectInsertPage.setDebug(debug);
304                 projectInsertPage.setName("page.project.insert");
305                 projectInsertPage.setFreenetInterface(freenetInterface);
306                 pages.put(PageType.PAGE_INSERT_PROJECT, projectInsertPage);
307         }
308
309         /**
310          * Shows the page with the given type.
311          *
312          * @param pageType
313          *            The page type to show
314          */
315         private void showPage(PageType pageType) {
316                 wizard.setPreviousEnabled(pageType.ordinal() > 0);
317                 wizard.setNextEnabled(pageType.ordinal() < (pages.size() - 1));
318                 wizard.setPage(pages.get(pageType));
319                 wizard.setTitle(pages.get(pageType).getHeading() + " - jSite");
320         }
321
322         /**
323          * Saves the configuration.
324          *
325          * @return <code>true</code> if the configuration could be saved,
326          *         <code>false</code> otherwise
327          */
328         private boolean saveConfiguration() {
329                 NodeManagerPage nodeManagerPage = (NodeManagerPage) pages.get(PageType.PAGE_NODE_MANAGER);
330                 configuration.setNodes(nodeManagerPage.getNodes());
331                 if (selectedNode != null) {
332                         configuration.setSelectedNode(selectedNode);
333                 }
334
335                 ProjectPage projectPage = (ProjectPage) pages.get(PageType.PAGE_PROJECTS);
336                 configuration.setProjects(projectPage.getProjects());
337
338                 return configuration.save();
339         }
340
341         /**
342          * Finds a supported locale for the given locale.
343          *
344          * @param forLocale
345          *            The locale to find a supported locale for
346          * @return The supported locale that was found, or the default locale if no
347          *         supported locale could be found
348          */
349         private Locale findSupportedLocale(Locale forLocale) {
350                 for (Locale locale : SUPPORTED_LOCALES) {
351                         if (locale.equals(forLocale)) {
352                                 return locale;
353                         }
354                 }
355                 for (Locale locale : SUPPORTED_LOCALES) {
356                         if (locale.getCountry().equals(forLocale.getCountry()) && locale.getLanguage().equals(forLocale.getLanguage())) {
357                                 return locale;
358                         }
359                 }
360                 for (Locale locale : SUPPORTED_LOCALES) {
361                         if (locale.getLanguage().equals(forLocale.getLanguage())) {
362                                 return locale;
363                         }
364                 }
365                 return SUPPORTED_LOCALES[0];
366         }
367
368         /**
369          * Returns the version.
370          *
371          * @return The version
372          */
373         public static final Version getVersion() {
374                 return VERSION;
375         }
376
377         //
378         // ACTIONS
379         //
380
381         /**
382          * Switches the language of the interface to the given locale.
383          *
384          * @param locale
385          *            The locale to switch to
386          */
387         private void switchLanguage(Locale locale) {
388                 Locale supportedLocale = findSupportedLocale(locale);
389                 Action languageAction = languageActions.get(supportedLocale);
390                 JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) languageAction.getValue("menuItem");
391                 menuItem.setSelected(true);
392                 I18n.setLocale(supportedLocale);
393                 for (Runnable i18nRunnable : I18nContainer.getInstance()) {
394                         try {
395                                 i18nRunnable.run();
396                         } catch (Throwable t) {
397                                 /* we probably shouldn't swallow this. */
398                         }
399                 }
400                 wizard.setPage(wizard.getPage());
401                 configuration.setLocale(supportedLocale);
402         }
403
404         //
405         // INTERFACE ListSelectionListener
406         //
407
408         /**
409          * {@inheritDoc}
410          */
411         public void valueChanged(ListSelectionEvent e) {
412                 JList list = (JList) e.getSource();
413                 int selectedRow = list.getSelectedIndex();
414                 wizard.setNextEnabled(selectedRow > -1);
415         }
416
417         //
418         // INTERFACE WizardListener
419         //
420
421         /**
422          * {@inheritDoc}
423          */
424         public void wizardNextPressed(TWizard wizard) {
425                 String pageName = wizard.getPage().getName();
426                 if ("page.node-manager".equals(pageName)) {
427                         showPage(PageType.PAGE_PROJECTS);
428                 } else if ("page.project".equals(pageName)) {
429                         ProjectPage projectPage = (ProjectPage) wizard.getPage();
430                         Project project = projectPage.getSelectedProject();
431                         if ((project.getLocalPath() == null) || (project.getLocalPath().trim().length() == 0)) {
432                                 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project.warning.no-local-path"), null, JOptionPane.ERROR_MESSAGE);
433                                 return;
434                         }
435                         if ((project.getPath() == null) || (project.getPath().trim().length() == 0)) {
436                                 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project.warning.no-path"), null, JOptionPane.ERROR_MESSAGE);
437                                 return;
438                         }
439                         ((ProjectFilesPage) pages.get(PageType.PAGE_PROJECT_FILES)).setProject(project);
440                         ((ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT)).setProject(project);
441                         showPage(PageType.PAGE_PROJECT_FILES);
442                 } else if ("page.project.files".equals(pageName)) {
443                         ProjectPage projectPage = (ProjectPage) pages.get(PageType.PAGE_PROJECTS);
444                         Project project = projectPage.getSelectedProject();
445                         if (selectedNode == null) {
446                                 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.no-node-selected"), null, JOptionPane.ERROR_MESSAGE);
447                                 return;
448                         }
449                         if (project.getIndexFile() == null) {
450                                 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.empty-index"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) {
451                                         return;
452                                 }
453                         } else {
454                                 File indexFile = new File(project.getLocalPath(), project.getIndexFile());
455                                 if (!indexFile.exists()) {
456                                         JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.index-missing"), null, JOptionPane.ERROR_MESSAGE);
457                                         return;
458                                 }
459                         }
460                         String indexFile = project.getIndexFile();
461                         boolean hasIndexFile = (indexFile != null);
462                         if (hasIndexFile && !project.getFileOption(indexFile).getContainer().equals("")) {
463                                 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.container-index"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) {
464                                         return;
465                                 }
466                         }
467                         if (hasIndexFile && !project.getFileOption(indexFile).getMimeType().equals("text/html")) {
468                                 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.project-files.index-not-html"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) {
469                                         return;
470                                 }
471                         }
472                         Map<String, FileOption> fileOptions = project.getFileOptions();
473                         Set<Entry<String, FileOption>> fileOptionEntries = fileOptions.entrySet();
474                         for (Entry<String, FileOption> fileOptionEntry : fileOptionEntries) {
475                                 FileOption fileOption = fileOptionEntry.getValue();
476                                 if (!fileOption.isInsert() && ((fileOption.getCustomKey().length() == 0) || "CHK@".equals(fileOption.getCustomKey()))) {
477                                         JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.project-files.no-custom-key"), fileOptionEntry.getKey()), null, JOptionPane.ERROR_MESSAGE);
478                                         return;
479                                 }
480                         }
481                         boolean nodeRunning = false;
482                         try {
483                                 nodeRunning = freenetInterface.isNodePresent();
484                         } catch (IOException e) {
485                                 /* ignore. */
486                         }
487                         if (!nodeRunning) {
488                                 JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.no-node-running"), null, JOptionPane.ERROR_MESSAGE);
489                                 return;
490                         }
491                         configuration.save();
492                         showPage(PageType.PAGE_INSERT_PROJECT);
493                         ((ProjectInsertPage) pages.get(PageType.PAGE_INSERT_PROJECT)).startInsert();
494                         nodeMenu.setEnabled(false);
495                 } else if ("page.project.insert".equals(pageName)) {
496                         showPage(PageType.PAGE_PROJECTS);
497                         nodeMenu.setEnabled(true);
498                 }
499         }
500
501         /**
502          * {@inheritDoc}
503          */
504         public void wizardPreviousPressed(TWizard wizard) {
505                 String pageName = wizard.getPage().getName();
506                 if ("page.project".equals(pageName)) {
507                         showPage(PageType.PAGE_NODE_MANAGER);
508                 } else if ("page.project.files".equals(pageName)) {
509                         showPage(PageType.PAGE_PROJECTS);
510                 } else if ("page.project.insert".equals(pageName)) {
511                         showPage(PageType.PAGE_PROJECT_FILES);
512                 }
513         }
514
515         /**
516          * {@inheritDoc}
517          */
518         public void wizardQuitPressed(TWizard wizard) {
519                 if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.quit.question"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) {
520                         if (saveConfiguration()) {
521                                 System.exit(0);
522                         }
523                         if (JOptionPane.showConfirmDialog(wizard, I18n.getMessage("jsite.quit.config-not-saved"), null, JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) {
524                                 System.exit(0);
525                         }
526                 }
527         }
528
529         //
530         // INTERFACE NodeManagerListener
531         //
532
533         /**
534          * {@inheritDoc}
535          */
536         public void nodesUpdated(Node[] nodes) {
537                 nodeMenu.removeAll();
538                 ButtonGroup nodeButtonGroup = new ButtonGroup();
539                 Node newSelectedNode = null;
540                 for (Node node : nodes) {
541                         JRadioButtonMenuItem nodeMenuItem = new JRadioButtonMenuItem(node.getName());
542                         nodeMenuItem.putClientProperty("Node", node);
543                         nodeMenuItem.addActionListener(this);
544                         nodeButtonGroup.add(nodeMenuItem);
545                         if (node.equals(selectedNode)) {
546                                 newSelectedNode = node;
547                                 nodeMenuItem.setSelected(true);
548                         }
549                         nodeMenu.add(nodeMenuItem);
550                 }
551                 nodeMenu.addSeparator();
552                 nodeMenu.add(manageNodeAction);
553                 selectedNode = newSelectedNode;
554                 freenetInterface.setNode(selectedNode);
555         }
556
557         /**
558          * {@inheritDoc}
559          */
560         public void actionPerformed(ActionEvent e) {
561                 Object source = e.getSource();
562                 if (source instanceof JRadioButtonMenuItem) {
563                         JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) source;
564                         Node node = (Node) menuItem.getClientProperty("Node");
565                         selectedNode = node;
566                         freenetInterface.setNode(selectedNode);
567                 }
568         }
569
570         //
571         // MAIN METHOD
572         //
573
574         /**
575          * Main method that is called by the VM.
576          *
577          * @param args
578          *            The command-line arguments
579          */
580         public static void main(String[] args) {
581                 String configFilename = null;
582                 boolean nextIsConfigFilename = false;
583                 for (String argument : args) {
584                         if (nextIsConfigFilename) {
585                                 configFilename = argument;
586                                 nextIsConfigFilename = false;
587                         }
588                         if ("--help".equals(argument)) {
589                                 printHelp();
590                                 return;
591                         } else if ("--debug".equals(argument)) {
592                                 debug = true;
593                         } else if ("--config-file".equals(argument)) {
594                                 nextIsConfigFilename = true;
595                         }
596                 }
597                 if (nextIsConfigFilename) {
598                         System.out.println("--config-file needs parameter!");
599                         return;
600                 }
601                 new Main(configFilename);
602         }
603
604         /**
605          * Prints a small syntax help.
606          */
607         private static void printHelp() {
608                 System.out.println("--help\tshows this cruft");
609                 System.out.println("--debug\tenables some debug output");
610                 System.out.println("--config-file <file>\tuse specified configuration file");
611         }
612
613 }