OSDN Git Service

画面のプロファイル生成処理で共通化できる部分を共通化
[coroid/inqubus.git] / frontend / src / yukihane / inqubus / Main.java
index 2690ec7..c609389 100644 (file)
@@ -1,8 +1,8 @@
 package yukihane.inqubus;
 
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
+import java.io.IOException;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.swing.JOptionPane;
@@ -10,7 +10,9 @@ import javax.swing.UIManager;
 import javax.swing.UIManager.LookAndFeelInfo;
 import javax.swing.UnsupportedLookAndFeelException;
 import org.apache.commons.configuration.ConfigurationException;
+import yukihane.inqubus.config.Config;
 import yukihane.inqubus.gui.MainFrame;
+import yukihane.inqubus.saccubus.prompt.Prompt;
 
 /**
  * いんきゅばす起動クラス.
@@ -21,8 +23,7 @@ public class Main {
     private static final Logger logger = Logger.getLogger(Main.class.getName());
 
     public static void main(String args[]) {
-        final FileSystem fileSystem = FileSystems.getDefault();
-        final Path path = fileSystem.getPath("inqubus.xml");
+        final Path path = Paths.get("inqubus.xml");
         boolean showWelcome;
         try {
             Config.INSTANCE.load(path.toString());
@@ -31,12 +32,25 @@ public class Main {
             showWelcome = true;
             logger.log(Level.FINER, "コンフィグファイルが無いためデフォルト値で起動", ex);
         }
+
+        // 第1引数がメールアドレスと思しき時はさきゅばすフォーマットのコマンドラインであるとみなしてパース
+        if (args.length > 0 && args[0].contains("@")) {
+            try {
+                new Prompt().main(args);
+            } catch (Exception ex) {
+                logger.log(Level.SEVERE, "処理が正常終了しませんでした", ex);
+            }
+            return;
+        }
+
         final RunWindow invoke = new RunWindow(showWelcome);
         java.awt.EventQueue.invokeLater(invoke);
     }
 
     private static class RunWindow implements Runnable {
+
         private final boolean showWelcome;
+
         private RunWindow(boolean showWelcome) {
             this.showWelcome = showWelcome;
         }
@@ -47,8 +61,10 @@ public class Main {
             final MainFrame frame = new MainFrame();
             frame.startWatcher();
             frame.setVisible(true);
-            if(showWelcome) {
-                JOptionPane.showMessageDialog(frame, "<html>設定はメニューの <b>ツール > オプション</b> から行えます</html>", "いんきゅばすへようこそ", JOptionPane.INFORMATION_MESSAGE);
+            if (showWelcome) {
+                JOptionPane.showMessageDialog(frame,
+                        "<html>設定はメニューの <b>ツール > オプション</b> から行えます</html>",
+                        "いんきゅばすへようこそ", JOptionPane.INFORMATION_MESSAGE);
             }
         }
     }