Some fixes: output types, libraries, remote
[nikiroo-utils.git] / src / be / nikiroo / fanfix / Main.java
index 9ac48845ce87d4bc57416bfd2daf7e7f30fa4364..c17a1d8b988f0a52c7c763efd9bad67f48bebd92 100644 (file)
@@ -253,12 +253,30 @@ public class Main {
                                updates.ok(); // we consider it read
                                break;
                        case LIST:
+                               if (BasicReader.getReader() == null) {
+                                       Instance.syserr(new Exception(
+                                                       "No reader type has been configured"));
+                                       exitCode = 10;
+                                       break;
+                               }
                                exitCode = list(sourceString);
                                break;
                        case READ:
+                               if (BasicReader.getReader() == null) {
+                                       Instance.syserr(new Exception(
+                                                       "No reader type has been configured"));
+                                       exitCode = 10;
+                                       break;
+                               }
                                exitCode = read(luid, chapString, true);
                                break;
                        case READ_URL:
+                               if (BasicReader.getReader() == null) {
+                                       Instance.syserr(new Exception(
+                                                       "No reader type has been configured"));
+                                       exitCode = 10;
+                                       break;
+                               }
                                exitCode = read(urlString, chapString, false);
                                break;
                        case HELP:
@@ -277,6 +295,12 @@ public class Main {
                                updates.ok(); // we consider it read
                                break;
                        case START:
+                               if (BasicReader.getReader() == null) {
+                                       Instance.syserr(new Exception(
+                                                       "No reader type has been configured"));
+                                       exitCode = 10;
+                                       break;
+                               }
                                BasicReader.getReader().browse(null);
                                break;
                        case SERVER:
@@ -293,7 +317,7 @@ public class Main {
                                }
                                return;
                        case REMOTE:
-                               exitCode = 255;
+                               exitCode = 255; // should not be reachable (REMOTE -> START)
                                break;
                        }
                }
@@ -348,7 +372,7 @@ public class Main {
         */
        public static int export(String luid, String typeString, String target,
                        Progress pg) {
-               OutputType type = OutputType.valueOfNullOkUC(typeString);
+               OutputType type = OutputType.valueOfNullOkUC(typeString, null);
                if (type == null) {
                        Instance.syserr(new Exception(trans(StringId.OUTPUT_DESC,
                                        typeString)));
@@ -453,7 +477,7 @@ public class Main {
                                sourceName = sourceName.substring("file://".length());
                        }
 
-                       OutputType type = OutputType.valueOfAllOkUC(typeString);
+                       OutputType type = OutputType.valueOfAllOkUC(typeString, null);
                        if (type == null) {
                                Instance.syserr(new IOException(trans(
                                                StringId.ERR_BAD_OUTPUT_TYPE, typeString)));