creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1374590 - in /creadur/whisker/trunk/apache-whisker-cli/src: main/java/org/apache/creadur/whisker/cli/Main.java test/java/org/apache/creadur/whisker/cli/TestMain.java
Date Sat, 18 Aug 2012 14:29:41 GMT
Author: rdonkin
Date: Sat Aug 18 14:29:41 2012
New Revision: 1374590

URL: http://svn.apache.org/viewvc?rev=1374590&view=rev
Log:
Fixed bug which limit command line to help (Doh!). Thanks for Chip Childers for the report
and the patch 
http://mail-archives.apache.org/mod_mbox/creadur-dev/201208.mbox/%3CCA%2B96GG7qfVF7qEVVoF%2Bd-Tk%3D-db%2BEUPqKmS2_-24mCVxmQwb%3DQ%40mail.gmail.com%3E.


Added:
    creadur/whisker/trunk/apache-whisker-cli/src/test/java/org/apache/creadur/whisker/cli/TestMain.java
  (with props)
Modified:
    creadur/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/creadur/whisker/cli/Main.java

Modified: creadur/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/creadur/whisker/cli/Main.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/creadur/whisker/cli/Main.java?rev=1374590&r1=1374589&r2=1374590&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/creadur/whisker/cli/Main.java
(original)
+++ creadur/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/creadur/whisker/cli/Main.java
Sat Aug 18 14:29:41 2012
@@ -46,7 +46,7 @@ public final class Main {
     /**
      * Appended to help.
      */
-    private static final String HELP_FOOTER = 
+    private static final String HELP_FOOTER =
         "\nApache Whisker assists assembled applications " +
         "maintain correct legal documentation. " +
         "Whisker is part of the " +
@@ -129,7 +129,7 @@ public final class Main {
      * Configures the application from the command line given.
      * @param commandLine not null
      * @return not null
-     * @throws MissingOptionException when a mandatory option 
+     * @throws MissingOptionException when a mandatory option
      * has not been supplied
      */
     private Whisker configure(
@@ -184,13 +184,17 @@ public final class Main {
      * @param args not null
      * @return true when command line contains option for help,
      * false otherwise
-     * @throws ParseException 
+     * @throws ParseException
      */
-    private boolean printHelp(String[] args) throws ParseException {
+    public boolean printHelp(String[] args) throws ParseException {
         final CommandLineOption help = CommandLineOption.PRINT_HELP;
-        return help.isSetOn(
+        try {
+            return help.isSetOn(
                 parser().parse(new Options().addOption(
                         help.create()), args));
+        } catch (ParseException e) {
+            return false;
+        }
     }
 
     /**

Added: creadur/whisker/trunk/apache-whisker-cli/src/test/java/org/apache/creadur/whisker/cli/TestMain.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-cli/src/test/java/org/apache/creadur/whisker/cli/TestMain.java?rev=1374590&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-cli/src/test/java/org/apache/creadur/whisker/cli/TestMain.java
(added)
+++ creadur/whisker/trunk/apache-whisker-cli/src/test/java/org/apache/creadur/whisker/cli/TestMain.java
Sat Aug 18 14:29:41 2012
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.creadur.whisker.cli;
+
+import org.apache.creadur.whisker.app.Whisker;
+
+import junit.framework.TestCase;
+
+public class TestMain extends TestCase {
+
+    Main subject;
+
+    @Override
+    protected void setUp() throws Exception {
+       super.setUp();
+       subject = new Main(new Whisker());
+    }
+
+    public void testIsHelpHelp() throws Exception {
+        assertTrue(subject.printHelp(args("--help")));
+    }
+
+    public void testIsGenerateHelp() throws Exception {
+        assertFalse(subject.printHelp(args("--generate")));
+    }
+
+    public void testIsAuditHelp() throws Exception {
+        assertFalse(subject.printHelp(args("--audit")));
+    }
+
+    private String[] args(String ...strings) {
+        return strings;
+    }
+}

Propchange: creadur/whisker/trunk/apache-whisker-cli/src/test/java/org/apache/creadur/whisker/cli/TestMain.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message