You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by rd...@apache.org on 2012/08/20 19:46:26 UTC
svn commit: r1375135 - in /creadur/whisker/trunk/apache-whisker-cli/src:
main/java/org/apache/creadur/whisker/cli/CommandLineOption.java
main/java/org/apache/creadur/whisker/cli/Main.java
test/java/org/apache/creadur/whisker/cli/TestCommandParsing.java
Author: rdonkin
Date: Mon Aug 20 17:46:25 2012
New Revision: 1375135
URL: http://svn.apache.org/viewvc?rev=1375135&view=rev
Log:
Start tooling skeleton meta-data generation for the command line
Modified:
creadur/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/creadur/whisker/cli/CommandLineOption.java
creadur/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/creadur/whisker/cli/Main.java
creadur/whisker/trunk/apache-whisker-cli/src/test/java/org/apache/creadur/whisker/cli/TestCommandParsing.java
Modified: creadur/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/creadur/whisker/cli/CommandLineOption.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/creadur/whisker/cli/CommandLineOption.java?rev=1375135&r1=1375134&r2=1375135&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/creadur/whisker/cli/CommandLineOption.java (original)
+++ creadur/whisker/trunk/apache-whisker-cli/src/main/java/org/apache/creadur/whisker/cli/CommandLineOption.java Mon Aug 20 17:46:25 2012
@@ -30,18 +30,21 @@ import org.apache.commons.cli.Options;
public enum CommandLineOption {
/** License descriptor command line argument. */
- LICENSE_DESCRIPTION("license-descriptor", 'l',
+ LICENSE_DESCRIPTION("license-descriptor", 'l',
"use given license descriptor", true, "file", false),
/** Application source command line argument. */
SOURCE("source", 's', "application source", false, "dir", false),
/** Generation command line argument. */
- ACT_TO_GENERATE("generate", 'g',
+ ACT_TO_GENERATE("generate", 'g',
"generate license and notice", false, null, true),
/** Audit command line argument. */
ACT_TO_AUDIT("audit", 'a', "report audit details", false, null, true),
+ /** Generate skeleton mete-data command line argument. */
+ ACT_TO_SKELETON("skeleton", 't',
+ "generates skeleton meta-data", false, null, true),
/** Print help then exit, ignoring other options. */
PRINT_HELP("help", 'h', "print help then exit, ignoring other options.", false, null, false);
-
+
/**
* Creates options for the command line.
* @return not null
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=1375135&r1=1375134&r2=1375135&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 Mon Aug 20 17:46:25 2012
@@ -145,6 +145,8 @@ public final class Main {
whisker.setAct(Act.AUDIT);
} else if (CommandLineOption.ACT_TO_GENERATE.isSetOn(commandLine)) {
whisker.setAct(Act.GENERATE);
+ } else if (CommandLineOption.ACT_TO_SKELETON.isSetOn(commandLine)) {
+ whisker.setAct(Act.TEMPLATE);
}
if (whisker.getSource() == null
Modified: creadur/whisker/trunk/apache-whisker-cli/src/test/java/org/apache/creadur/whisker/cli/TestCommandParsing.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-cli/src/test/java/org/apache/creadur/whisker/cli/TestCommandParsing.java?rev=1375135&r1=1375134&r2=1375135&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-cli/src/test/java/org/apache/creadur/whisker/cli/TestCommandParsing.java (original)
+++ creadur/whisker/trunk/apache-whisker-cli/src/test/java/org/apache/creadur/whisker/cli/TestCommandParsing.java Mon Aug 20 17:46:25 2012
@@ -14,7 +14,7 @@
* "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.
+ * under the License.
*/
package org.apache.creadur.whisker.cli;
@@ -30,13 +30,13 @@ import org.apache.creadur.whisker.app.lo
*
*/
public class TestCommandParsing extends TestCase {
-
+
/**
- *
+ *
*/
private static final String LONG_OPT = "--";
/**
- *
+ *
*/
private static final String SHORT_OPT = "-";
private Main subject;
@@ -49,24 +49,29 @@ public class TestCommandParsing extends
public void testGenerateAndAuditAreMutuallyExclusive() throws Exception {
try {
subject.configure(
- args(longOpt(CommandLineOption.LICENSE_DESCRIPTION.getLongName()), "PATH",
+ args(longOpt(CommandLineOption.LICENSE_DESCRIPTION.getLongName()), "PATH",
longOpt(CommandLineOption.ACT_TO_AUDIT.getLongName()),
longOpt(CommandLineOption.ACT_TO_GENERATE.getLongName())));
-
+
fail("Expected audit and generate to together to throw exception");
} catch (AlreadySelectedException e) {
// expected
}
}
-
+
public void testSetGenerateAct() throws Exception {
checkSetActForOption(Act.GENERATE, CommandLineOption.ACT_TO_GENERATE);
}
-
+
public void testSetAuditAct() throws Exception {
checkSetActForOption(Act.AUDIT, CommandLineOption.ACT_TO_AUDIT);
}
+ public void testSetSkeletonAct() throws Exception {
+ checkSetActForOption(Act.TEMPLATE, CommandLineOption.ACT_TO_SKELETON);
+ }
+
+
/**
* @param act
* @param option
@@ -75,10 +80,10 @@ public class TestCommandParsing extends
private void checkSetActForOption(Act act, CommandLineOption option)
throws ParseException {
assertEquals(act + " arg should set property on Whisker", act, subject.configure(
- args(longOpt(CommandLineOption.LICENSE_DESCRIPTION.getLongName()), "PATH",
+ args(longOpt(CommandLineOption.LICENSE_DESCRIPTION.getLongName()), "PATH",
shortOpt(CommandLineOption.SOURCE.getShortName()), "path", longOpt(option.getLongName()))).getAct());
assertEquals(act + "Audit arg should set property on Whisker", act, subject.configure(
- args(longOpt(CommandLineOption.LICENSE_DESCRIPTION.getLongName()), "PATH",
+ args(longOpt(CommandLineOption.LICENSE_DESCRIPTION.getLongName()), "PATH",
shortOpt(CommandLineOption.SOURCE.getShortName()), "path", shortOpt(option.getShortName()))).getAct());
}
@@ -87,10 +92,10 @@ public class TestCommandParsing extends
checkSourceWithPath("/");
checkSourceWithPath("relative");
}
-
+
public void testAuditRequiresSource() throws Exception {
try {
- subject.configure(args(
+ subject.configure(args(
longOpt(CommandLineOption.ACT_TO_AUDIT.getLongName()),
shortOpt(CommandLineOption.LICENSE_DESCRIPTION.getShortName()), "some/path"));
fail("Audit requires source");
@@ -98,7 +103,7 @@ public class TestCommandParsing extends
// Expected
}
}
-
+
/**
* @param aPath
*/
@@ -107,15 +112,15 @@ public class TestCommandParsing extends
checkSource(aPath, longOpt(CommandLineOption.SOURCE.getLongName()));
}
-
+
private void checkSource(String aPath, String arg) throws ParseException {
- assertEquals("Source arg should set property on Whisker", aPath,
- subject.configure(args(arg, aPath,
+ assertEquals("Source arg should set property on Whisker", aPath,
+ subject.configure(args(arg, aPath,
longOpt(CommandLineOption.ACT_TO_AUDIT.getLongName()),
shortOpt(CommandLineOption.LICENSE_DESCRIPTION.getShortName()), "Whatever/bin")).getSource());
}
-
-
+
+
public void testSetLicenseDescriptorShortByCLI() throws Exception {
exerciseShortLicenseDescriptionWithPath("/some/path");
exerciseShortLicenseDescriptionWithPath("another/path");
@@ -123,7 +128,7 @@ public class TestCommandParsing extends
exerciseShortLicenseDescriptionWithPath("");
exerciseShortLicenseDescriptionWithPath("http://url.style/path");
}
-
+
public void testSetLicenseDescriptorLongByCLI() throws Exception {
exerciseLongLicenseDescriptionWithPath("/some/path");
exerciseLongLicenseDescriptionWithPath("another/path");
@@ -147,7 +152,7 @@ public class TestCommandParsing extends
private String shortOpt(char licenseDescriptorShortOpt) {
return SHORT_OPT + licenseDescriptorShortOpt;
}
-
+
/**
* @param aPath
*/
@@ -172,12 +177,12 @@ public class TestCommandParsing extends
*/
private void exerciseLicenseDescriptor(String aPath, String arg)
throws ParseException {
- assertEquals("License descriptor arg should set property on Whisker", aPath,
+ assertEquals("License descriptor arg should set property on Whisker", aPath,
((StreamableClassPathResource)subject.configure(
args(arg, aPath, longOpt(CommandLineOption.ACT_TO_GENERATE.getLongName())))
.getLicenseDescriptor()).getName());
}
-
+
private String[] args(String ...strings) {
return strings;
}