You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by sg...@apache.org on 2008/07/18 23:50:57 UTC
svn commit: r678054 - in /commons/proper/exec/trunk/src:
main/java/org/apache/commons/exec/CommandLine.java
test/java/org/apache/commons/exec/CommandLineTest.java
Author: sgoeschl
Date: Fri Jul 18 14:50:57 2008
New Revision: 678054
URL: http://svn.apache.org/viewvc?rev=678054&view=rev
Log:
Removing the syntactic sugar of adding two command line parameters in one method invocation since this can be easily done with the existing API.
Modified:
commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java
commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java
Modified: commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java?rev=678054&r1=678053&r2=678054&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java (original)
+++ commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java Fri Jul 18 14:50:57 2008
@@ -158,29 +158,6 @@
}
/**
- * Add exactly two arguments in one invocation. Handles parsing of quotes and whitespace.
- *
- * @param argument1 The first argument
- * @param argument2 The second argument
- * @return The command line itself
- */
- public CommandLine addArguments(final String argument1, final String argument2) {
- return this.addArguments(argument1, true).addArguments(argument2, true);
- }
-
- /**
- * Add exactly two arguments in one invocation.
- *
- * @param argument1 The first argument
- * @param argument2 The second argument
- * @param handleQuoting Add the argument with/without handling quoting
- * @return The command line itself
- */
- public CommandLine addArguments(final String argument1, final String argument2, boolean handleQuoting) {
- return this.addArguments(argument1, handleQuoting).addArguments(argument2, handleQuoting);
- }
-
- /**
* Add multiple arguments. Handles parsing of quotes and whitespace.
* Please note that the parsing can have undesired side-effects therefore
* it is recommended to build the command line incrementally.
Modified: commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java
URL: http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java?rev=678054&r1=678053&r2=678054&view=diff
==============================================================================
--- commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java (original)
+++ commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/CommandLineTest.java Fri Jul 18 14:50:57 2008
@@ -167,12 +167,24 @@
assertEquals(new String[] {"test"}, cmdl.toStrings());
}
+ /**
+ * A little example how to add two command line arguments
+ * in one line, e.g. to make commenting out some options
+ * less error prone.
+ */
public void testAddTwoArguments() {
- CommandLine cmdl = new CommandLine("test");
- cmdl.addArguments("foo", "bar");
- assertEquals("test foo bar", cmdl.toString());
- assertEquals(new String[] {"test", "foo", "bar"}, cmdl.toStrings());
- }
+
+ CommandLine userAddCL1 = new CommandLine("useradd");
+ userAddCL1.addArgument("-g");
+ userAddCL1.addArgument("tomcat");
+ userAddCL1.addArgument("foo");
+
+ CommandLine userAddCL2 = new CommandLine("useradd");
+ userAddCL2.addArgument("-g").addArgument("tomcat");
+ userAddCL2.addArgument("foo");
+
+ assertEquals(userAddCL1.toString(), userAddCL2.toString());
+ }
public void testParseCommandLine() {
CommandLine cmdl = CommandLine.parse("test foo bar");