You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Emmanuel Bourg (JIRA)" <ji...@apache.org> on 2011/04/21 13:07:05 UTC

[jira] [Created] (CLI-216) Optional support for concatenated option in the DefaultParser

Optional support for concatenated option in the DefaultParser
-------------------------------------------------------------

                 Key: CLI-216
                 URL: https://issues.apache.org/jira/browse/CLI-216
             Project: Commons CLI
          Issue Type: Improvement
          Components: Parser
    Affects Versions: 1.3
            Reporter: Emmanuel Bourg
             Fix For: 1.3


DefaultParser supports the concatenated options of the PosixParser (i.e tar -zxvf), but in many cases this behavior is not desirable. This should be made optional.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (CLI-216) Optional support for concatenated option in the DefaultParser

Posted by "Hartmut Lang (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLI-216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13150582#comment-13150582 ] 

Hartmut Lang commented on CLI-216:
----------------------------------

Just to get an impression on this issue:
 * In which cases do you not want such a behavior?
 * Where could it be disabled, during options building or during parsing?
                
> Optional support for concatenated option in the DefaultParser
> -------------------------------------------------------------
>
>                 Key: CLI-216
>                 URL: https://issues.apache.org/jira/browse/CLI-216
>             Project: Commons CLI
>          Issue Type: Improvement
>          Components: Parser
>    Affects Versions: 1.3
>            Reporter: Emmanuel Bourg
>             Fix For: 1.3
>
>
> DefaultParser supports the concatenated options of the PosixParser (i.e tar -zxvf), but in many cases this behavior is not desirable. This should be made optional.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CLI-216) Optional support for concatenated option in the DefaultParser

Posted by "Emmanuel Bourg (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLI-216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13156679#comment-13156679 ] 

Emmanuel Bourg commented on CLI-216:
------------------------------------

It's not necessarily related to CLI-217. If there was a "ver" long option, and "v", "e", "r" short options, there is still an ambiguity if "-ver" appears on the command line.

                
> Optional support for concatenated option in the DefaultParser
> -------------------------------------------------------------
>
>                 Key: CLI-216
>                 URL: https://issues.apache.org/jira/browse/CLI-216
>             Project: Commons CLI
>          Issue Type: Improvement
>          Components: Parser
>    Affects Versions: 1.3
>            Reporter: Emmanuel Bourg
>             Fix For: 1.3
>
>
> DefaultParser supports the concatenated options of the PosixParser (i.e tar -zxvf), but in many cases this behavior is not desirable. This should be made optional.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CLI-216) Optional support for concatenated option in the DefaultParser

Posted by "Hartmut Lang (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLI-216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13150781#comment-13150781 ] 

Hartmut Lang commented on CLI-216:
----------------------------------

I thought of a use-case, but so far could not find one.
Look at the test-cases below. They run perfect with Default- and Posix-Parser.

{code}
    public void testBursting2() throws Exception
    {
        String[] args = new String[]{"-zxvf", "file1", "-xzvf", "file2"};

        Options opts = new Options();
        opts.addOption(OptionBuilder.create("x"));
        opts.addOption(OptionBuilder.create("v"));
        opts.addOption(OptionBuilder.create("z"));
        opts.addOption(OptionBuilder.hasArg().create("f"));
        opts.addOption(OptionBuilder.hasArg().withLongOpt("zxvf").create());

        CommandLine cl = parser.parse(opts, args);
        assertTrue("Confirm -zxvf is set", cl.hasOption("zxvf"));
        assertEquals("Confirm arg of -zxvf", "file1" , cl.getOptionValue("zxvf"));
        assertTrue("Confirm -x is set", cl.hasOption("x"));
        assertTrue("Confirm -v is set", cl.hasOption("v"));
        assertTrue("Confirm -z is set", cl.hasOption("z"));
        assertTrue("Confirm -f is set", cl.hasOption("f"));
        assertEquals("Confirm arg of -f", "file2" , cl.getOptionValue("f"));
    }
    
    public void testBursting3() throws Exception
    {
        String[] args = new String[]{"-zx", "file1", "-zvxf", "file2"};

        Options opts = new Options();
        opts.addOption(OptionBuilder.create("x"));
        opts.addOption(OptionBuilder.create("v"));
        opts.addOption(OptionBuilder.create("z"));
        opts.addOption(OptionBuilder.hasArg().create("f"));
        opts.addOption(OptionBuilder.hasArg().withLongOpt("zxvf").create());

        CommandLine cl = parser.parse(opts, args);
        assertTrue("Confirm -zxvf is set", cl.hasOption("zxvf"));
        assertEquals("Confirm arg of -zxvf", "file1" , cl.getOptionValue("zxvf"));
        assertTrue("Confirm -x is set", cl.hasOption("x"));
        assertTrue("Confirm -v is set", cl.hasOption("v"));
        assertTrue("Confirm -z is set", cl.hasOption("z"));
        assertTrue("Confirm -f is set", cl.hasOption("f"));
        assertEquals("Confirm arg of -f", "file2" , cl.getOptionValue("f"));
    }

{code}

                
> Optional support for concatenated option in the DefaultParser
> -------------------------------------------------------------
>
>                 Key: CLI-216
>                 URL: https://issues.apache.org/jira/browse/CLI-216
>             Project: Commons CLI
>          Issue Type: Improvement
>          Components: Parser
>    Affects Versions: 1.3
>            Reporter: Emmanuel Bourg
>             Fix For: 1.3
>
>
> DefaultParser supports the concatenated options of the PosixParser (i.e tar -zxvf), but in many cases this behavior is not desirable. This should be made optional.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CLI-216) Optional support for concatenated option in the DefaultParser

Posted by "Emmanuel Bourg (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLI-216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13151101#comment-13151101 ] 

Emmanuel Bourg commented on CLI-216:
------------------------------------

I was thinking at something like v, e, r short options, and a 'version' long option. On typing -ver there is an ambiguity.
                
> Optional support for concatenated option in the DefaultParser
> -------------------------------------------------------------
>
>                 Key: CLI-216
>                 URL: https://issues.apache.org/jira/browse/CLI-216
>             Project: Commons CLI
>          Issue Type: Improvement
>          Components: Parser
>    Affects Versions: 1.3
>            Reporter: Emmanuel Bourg
>             Fix For: 1.3
>
>
> DefaultParser supports the concatenated options of the PosixParser (i.e tar -zxvf), but in many cases this behavior is not desirable. This should be made optional.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CLI-216) Optional support for concatenated option in the DefaultParser

Posted by "Hartmut Lang (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLI-216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13151132#comment-13151132 ] 

Hartmut Lang commented on CLI-216:
----------------------------------

In this example i think -ver will be the partial matched 'version' long-option.
So you expect to be the three short option 'v,e,r' , do you?
So this is more related to CLI-217, turn of the partial matching, right?
                
> Optional support for concatenated option in the DefaultParser
> -------------------------------------------------------------
>
>                 Key: CLI-216
>                 URL: https://issues.apache.org/jira/browse/CLI-216
>             Project: Commons CLI
>          Issue Type: Improvement
>          Components: Parser
>    Affects Versions: 1.3
>            Reporter: Emmanuel Bourg
>             Fix For: 1.3
>
>
> DefaultParser supports the concatenated options of the PosixParser (i.e tar -zxvf), but in many cases this behavior is not desirable. This should be made optional.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CLI-216) Optional support for concatenated option in the DefaultParser

Posted by "Emmanuel Bourg (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CLI-216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13150613#comment-13150613 ] 

Emmanuel Bourg commented on CLI-216:
------------------------------------

It would be disabled on the parser, the definition of the options is independent.

I don't have a use case in mind for disabling this behavior. I guess one can imagine it conflicts with the matching of a long option.
                
> Optional support for concatenated option in the DefaultParser
> -------------------------------------------------------------
>
>                 Key: CLI-216
>                 URL: https://issues.apache.org/jira/browse/CLI-216
>             Project: Commons CLI
>          Issue Type: Improvement
>          Components: Parser
>    Affects Versions: 1.3
>            Reporter: Emmanuel Bourg
>             Fix For: 1.3
>
>
> DefaultParser supports the concatenated options of the PosixParser (i.e tar -zxvf), but in many cases this behavior is not desirable. This should be made optional.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira