]> www.vanbest.org Git - tv_grab_nl_java/commitdiff
Implement --config-yes flag
authorJan-Pascal van Best <janpascal@vanbest.org>
Thu, 2 Jan 2014 20:31:15 +0000 (21:31 +0100)
committerJan-Pascal van Best <janpascal@vanbest.org>
Thu, 2 Jan 2014 20:31:15 +0000 (21:31 +0100)
src/main/java/org/vanbest/xmltv/Config.java
src/main/java/org/vanbest/xmltv/Main.java

index eea32fbcb3f4a864a0ff35f4b2d41933a4ce13da..1be747e3e4102955acb2cc35a4153ad6363822f3 100644 (file)
@@ -53,6 +53,7 @@ public class Config {
 
        // command-line options
        boolean quiet = false;
+        boolean configYes = false;
 
        String project_version;
        String build_time;
index 4b95700aeffeba1fc75445f374e15c4eb3ee521b..908f6e9a10355d11872c2cbbe4e9275282182173 100644 (file)
@@ -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<Channel> channels = new ArrayList<Channel>();
                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;
        }