From: Jan-Pascal van Best Date: Thu, 2 Jan 2014 20:31:15 +0000 (+0100) Subject: Implement --config-yes flag X-Git-Tag: v1.5.1~4 X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=62a3c2be2999fd79a4dba231c98ad75072c5bb55;p=tv_grab_nl_java Implement --config-yes flag --- diff --git a/src/main/java/org/vanbest/xmltv/Config.java b/src/main/java/org/vanbest/xmltv/Config.java index eea32fb..1be747e 100644 --- a/src/main/java/org/vanbest/xmltv/Config.java +++ b/src/main/java/org/vanbest/xmltv/Config.java @@ -53,6 +53,7 @@ public class Config { // command-line options boolean quiet = false; + boolean configYes = false; String project_version; String build_time; diff --git a/src/main/java/org/vanbest/xmltv/Main.java b/src/main/java/org/vanbest/xmltv/Main.java index 4b95700..908f6e9 100644 --- a/src/main/java/org/vanbest/xmltv/Main.java +++ b/src/main/java/org/vanbest/xmltv/Main.java @@ -175,20 +175,24 @@ public class Main { System.out .print("Delay between each request to the server (in milliseconds, default=" + config.niceMilliseconds + "):"); - while (true) { - String s = reader.readLine().toLowerCase(); - if (s.isEmpty()) { - break; - } - try { - config.niceMilliseconds = Integer.parseInt(s); - break; - } catch (NumberFormatException e) { - System.out.println("\"" + s - + "\" is not a valid number, please try again"); - continue; - } - } + if(config.configYes) { + System.out.println(); + } else { + while (true) { + String s = reader.readLine().toLowerCase(); + if (s.isEmpty()) { + break; + } + try { + config.niceMilliseconds = Integer.parseInt(s); + break; + } catch (NumberFormatException e) { + System.out.println("\"" + s + + "\" is not a valid number, please try again"); + continue; + } + } + } // TODO configure cache location // public String cacheDbHandle; @@ -217,6 +221,12 @@ public class Main { EPGSource guide = factory.createEPGSource(source, config); System.out.print(" Use \"" + guide.getName() + "\" (Y/N, default=" + (selected ? "Y" : "N") + "):"); + if(config.configYes) { + guides.add(guide); + System.out.println("Y"); + continue; + } + while (true) { String s = reader.readLine().toLowerCase(); if (s.isEmpty()) { @@ -235,8 +245,11 @@ public class Main { System.out.println("Please wait, fetching channel information..."); List channels = new ArrayList(); for (EPGSource guide : guides) { - channels.addAll(guide.getChannels()); + System.out.print(guide.getName()+"... "); + channels.addAll(guide.getChannels()); + System.out.println("OK"); } + System.out.println(); boolean all = false; boolean none = false; @@ -253,7 +266,7 @@ public class Main { System.out.println(selected ? "Y" : "N"); continue; } - if (all) { + if (all || config.configYes) { c.enabled = true; System.out.println("Y"); continue; @@ -374,6 +387,10 @@ public class Main { OptionBuilder.withLongOpt("configure") .withDescription("Interactive configuration") .create()) + .addOption( + OptionBuilder.withLongOpt("config-yes") + .withDescription("Answer 'yes' to all configuration questions") + .create()) .addOption( OptionBuilder.withLongOpt("config-file").hasArg() .withDescription("Configuration file location") @@ -463,6 +480,9 @@ public class Main { if (line.hasOption("configure")) { action = ACTION_CONFIGURE; } + if (line.hasOption("config-yes")) { + config.configYes = true; + } return action; }