+ if (exitCode != 255) {
+ switch (action) {
+ case IMPORT:
+ exitCode = imprt(urlString, pg);
+ updates.ok(); // we consider it read
+ break;
+ case EXPORT:
+ exitCode = export(luid, sourceString, target, pg);
+ updates.ok(); // we consider it read
+ break;
+ case CONVERT:
+ exitCode = convert(urlString, sourceString, target,
+ plusInfo == null ? false : plusInfo, pg);
+ updates.ok(); // we consider it read
+ break;
+ case LIST:
+ if (BasicReader.getReader() == null) {
+ Instance.getTraceHandler()
+ .error(new Exception(
+ "No reader type has been configured"));
+ exitCode = 10;
+ break;
+ }
+ exitCode = list(sourceString);
+ break;
+ case READ:
+ if (BasicReader.getReader() == null) {
+ Instance.getTraceHandler()
+ .error(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.getTraceHandler()
+ .error(new Exception(
+ "No reader type has been configured"));
+ exitCode = 10;
+ break;
+ }
+ exitCode = read(urlString, chapString, false);
+ break;
+ case HELP:
+ syntax(true);
+ exitCode = 0;
+ break;
+ case SET_READER:
+ exitCode = 255;
+ break;
+ case VERSION:
+ System.out
+ .println(String.format("Fanfix version %s"
+ + "%nhttps://github.com/nikiroo/fanfix/"
+ + "%n\tWritten by Nikiroo",
+ Version.getCurrentVersion()));
+ updates.ok(); // we consider it read
+ break;
+ case START:
+ if (BasicReader.getReader() == null) {
+ Instance.getTraceHandler()
+ .error(new Exception(
+ "No reader type has been configured"));
+ exitCode = 10;
+ break;
+ }
+ BasicReader.getReader().browse(null);
+ break;
+ case SERVER:
+ if (port == null) {
+ exitCode = 255;
+ break;
+ }
+ try {
+ ServerObject server = new RemoteLibraryServer(key, port);
+ server.setTraceHandler(Instance.getTraceHandler());
+ server.run();
+ } catch (IOException e) {
+ Instance.getTraceHandler().error(e);
+ }
+ return;
+ case STOP_SERVER:
+ if (port == null) {
+ exitCode = 255;
+ break;
+ }
+
+ new RemoteLibrary(key, host, port).exit();
+ break;
+ case REMOTE:
+ exitCode = 255; // should not be reachable (REMOTE -> START)
+ break;
+ }