Return-Path: X-Original-To: apmail-creadur-commits-archive@www.apache.org Delivered-To: apmail-creadur-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 23D5090F5 for ; Sat, 18 Aug 2012 14:30:29 +0000 (UTC) Received: (qmail 24541 invoked by uid 500); 18 Aug 2012 14:30:29 -0000 Delivered-To: apmail-creadur-commits-archive@creadur.apache.org Received: (qmail 24516 invoked by uid 500); 18 Aug 2012 14:30:29 -0000 Mailing-List: contact commits-help@creadur.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@creadur.apache.org Delivered-To: mailing list commits@creadur.apache.org Received: (qmail 24505 invoked by uid 99); 18 Aug 2012 14:30:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Aug 2012 14:30:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Aug 2012 14:30:26 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0EDA12388900 for ; Sat, 18 Aug 2012 14:29:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@creadur.apache.org From: rdonkin@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120818142942.0EDA12388900@eris.apache.org> 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