commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Siegfried Goeschl <siegfried.goes...@it20one.at>
Subject Re: [EXEC] Suggestion for CommandLine
Date Fri, 18 Jul 2008 21:52:09 GMT
Hi Peter,

actually no need for the syntactic sugar - see the test below

/**
 * 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 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());
}


Cheers,

Siegfried Goeschl

Peter Henderson wrote:
> Hi
>
> I hope this is the correct place for suggestions to Commons Exec.
>
>
> CommandLine
>
> Many command line arguments come in pairs, at the moment I have to call addArgument()
twice for each
> component in the paired argument, which is slightly messy + could lead to problems if
one of the
> pair is commented out later.
>
> Suggestion
> Add a 2 arg addArgument method for adding 2 command line arguments in one.
> (or perhaps use varargs?)
>
>
> example :-
> Before
>         CommandLine userAddCL = new CommandLine("useradd");
>         userAddCL.addArgument("-g");
>         userAddCL.addArgument("tomcat");
>         userAddCL.addArgument(username);
>
> After
>         CommandLine userAddCL = new CommandLine("useradd");
>         userAddCL.addArgument("-g", "tomcat");
>         userAddCL.addArgument(username);
>
>
>
>
> Peter Henderson.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message