[jira] Created: (CLI-169) HelpFormatter ignores Option's value separator

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (CLI-169) HelpFormatter ignores Option's value separator

JIRA jira@apache.org
HelpFormatter ignores Option's value separator
----------------------------------------------

                 Key: CLI-169
                 URL: https://issues.apache.org/jira/browse/CLI-169
             Project: Commons CLI
          Issue Type: Bug
          Components: CLI-1.x, Help formatter
    Affects Versions: 1.2
            Reporter: J. Lewis Muir
             Fix For: 1.2


The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:

{code}
Option option = new Option("B", "bsize", true, "block size in bytes");
option.setArgName("SIZE");
option.setValueSeparator('=');
{code}

is rendered like this:

{noformat}
-B,--bsize <SIZE>  block size in bytes
{noformat}

But I would expect it to be rendered like this:

{noformat}
-B,--bsize=<SIZE>  block size in bytes
{noformat}

For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.

For example, consider this option containing a short name and a specified value separator:

{code}
Option option = new Option("B", true, "block size in bytes");
option.setArgName("SIZE");
option.setValueSeparator('=');
{code}

The automatically generated usage message with my changes would look like this:

{noformat}
usage: app [-B=<SIZE>]
{noformat}

If the same option included a long name too:

{code}
Option option = new Option("B", "bsize", true, "block size in bytes");
option.setArgName("SIZE");
option.setValueSeparator('=');
{code}

with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:

{noformat}
usage: app [-B <SIZE>]
{noformat}

Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].


--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (CLI-169) HelpFormatter ignores Option's value separator

JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

J. Lewis Muir updated CLI-169:
------------------------------

    Attachment: use-value-separator-in-help-formatter.patch

> HelpFormatter ignores Option's value separator
> ----------------------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: CLI-1.x, Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>             Fix For: 1.2
>
>         Attachments: use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CLI-169) HelpFormatter ignores Option's value separator

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635196#action_12635196 ]

Emmanuel Bourg commented on CLI-169:
------------------------------------

Actually the value separator is not the character between the option and its value, it's a character that can be used to split a token into several values.

For example:

{code}--classpath foo.jar:bar.jar:cli.jar{code}

If the 'classpath' option is defined with ':' as value separator, it'll receive 3 values: foo.jar, bar.jar and cli.jar.

The javadoc isn't clear on the purpose of the value separator, I'll try to improve it.

> HelpFormatter ignores Option's value separator
> ----------------------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: CLI-1.x, Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>             Fix For: 1.2
>
>         Attachments: use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (CLI-169) HelpFormatter ignores Option's value separator

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bourg updated CLI-169:
-------------------------------

    Component/s:     (was: CLI-1.x)

> HelpFormatter ignores Option's value separator
> ----------------------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>             Fix For: 1.2
>
>         Attachments: use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CLI-169) HelpFormatter ignores Option's value separator

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635202#action_12635202 ]

J. Lewis Muir commented on CLI-169:
-----------------------------------

Hmm...that's a bummer.

The {{ls}} example at the bottom of [http://commons.apache.org/cli/usage.html] suggested to me the meaning I had come to.  Look at the {{--block-size=SIZE}} help output and then the creation of the corresponding option below with the call to {{withValueSeparator('=')}}.  If the meaning of the value separator is what you say, then this example seems wrong.  Now that I'm looking more closely at this example, it doesn't set the argument name to "SIZE" either.

Sorry for the bogus patch.

> HelpFormatter ignores Option's value separator
> ----------------------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>             Fix For: 1.2
>
>         Attachments: use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CLI-169) HelpFormatter ignores Option's value separator

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635261#action_12635261 ]

Emmanuel Bourg commented on CLI-169:
------------------------------------

You are right, this example will be changed with the next release.

> HelpFormatter ignores Option's value separator
> ----------------------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>             Fix For: 1.2
>
>         Attachments: use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (CLI-169) HelpFormatter ignores Option's value separator

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

J. Lewis Muir updated CLI-169:
------------------------------

    Attachment: long-opt-name-arg-separator.patch

> HelpFormatter ignores Option's value separator
> ----------------------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>             Fix For: 1.2
>
>         Attachments: long-opt-name-arg-separator.patch, use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CLI-169) HelpFormatter ignores Option's value separator

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635363#action_12635363 ]

J. Lewis Muir commented on CLI-169:
-----------------------------------

OK, I'm trying again.

I've added a {{longOptNameArgSeparator}} property to {{HelpFormatter}} to allow the long option name-argument separator to be specified.  The default is still the space character to maintain backward compatibility.

Now, if you have an option like:

{code}
Option option = new Option("B", "bsize", true, "block size in bytes");
option.setArgName("SIZE");
{code}

and you call {{setLongOptNameArgSeparator('=')}} on a {{HelpFormatter}} instance, the option would be rendered by that instance in the help message as:

{noformat}
-B,--bsize=<SIZE>
{noformat}

Attached is a patch with test cases.

Since this is now really a feature addition, I would understand if it can't go into the next release.  But I think it would be great if it could.

> HelpFormatter ignores Option's value separator
> ----------------------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>             Fix For: 1.2
>
>         Attachments: long-opt-name-arg-separator.patch, use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CLI-169) HelpFormatter ignores Option's value separator

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635428#action_12635428 ]

Emmanuel Bourg commented on CLI-169:
------------------------------------

This implies to change the parsers too. One might expect any character to be used as the option/value separator.

I would rather add a parameter to the HelpFormatter to instruct him to put a '=' between the option name and the argument name for long options. Something like 'setUseEqualSignWithLongOptions(true)'. Would that do what you want? Or do you need a finer control on the formatting of each option?

> HelpFormatter ignores Option's value separator
> ----------------------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>             Fix For: 1.2
>
>         Attachments: long-opt-name-arg-separator.patch, use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CLI-169) HelpFormatter ignores Option's value separator

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635449#action_12635449 ]

J. Lewis Muir commented on CLI-169:
-----------------------------------

I'd be fine with something like the {{setUseEqualSignWithLongOptions(true)}} you suggest.

I chose to parameterize the separator to make it a little more flexible.  My idea was to keep the parsers and the formatter decoupled.  If some new parser comes along that accepts options like {{--bsize+<SIZE>}}, then {{HelpFormatter}} would be able to handle that since the option long name-argument separator could be set to {{'+'}}.

If there were to be more coupling between the parsers and the formatter, I could see a {{longOptNameArgSeparator}} property getting added to {{Option}} and making the parsers use that.  Then {{HelpFormatter}} could just always use the {{longOptNameArgSeparator}} of each option it rendered (like what I initially did with the value separator).

Anyway, I'd be happy with {{setUseEqualSignWithLongOptions(true)}} you suggest.

> HelpFormatter ignores Option's value separator
> ----------------------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>             Fix For: 1.2
>
>         Attachments: long-opt-name-arg-separator.patch, use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CLI-169) HelpFormatter ignores Option's value separator

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12637884#action_12637884 ]

J. Lewis Muir commented on CLI-169:
-----------------------------------

Should I provide a modified patch for the {{setUseEqualSignWithLongOptions()}} approach, or are you planning to do that?

> HelpFormatter ignores Option's value separator
> ----------------------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>             Fix For: 1.2
>
>         Attachments: long-opt-name-arg-separator.patch, use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (CLI-169) HelpFormatter ignores Option's value separator

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

J. Lewis Muir updated CLI-169:
------------------------------

    Attachment: use-equal-sign-with-long-opts.patch

This patch provides the proposed {{setUseEqualSignWithLongOptions(boolean)}} behavior.

> HelpFormatter ignores Option's value separator
> ----------------------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>             Fix For: 1.2
>
>         Attachments: long-opt-name-arg-separator.patch, use-equal-sign-with-long-opts.patch, use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Issue Comment Edited: (CLI-169) HelpFormatter ignores Option's value separator

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12638536#action_12638536 ]

jlmuir edited comment on CLI-169 at 10/10/08 4:50 AM:
-------------------------------------------------------------

The patch named {{use-equal-sign-with-long-opts.patch}} provides the proposed {{setUseEqualSignWithLongOptions(boolean)}} behavior.

      was (Author: jlmuir):
    This patch provides the proposed {{setUseEqualSignWithLongOptions(boolean)}} behavior.
 

> HelpFormatter ignores Option's value separator
> ----------------------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Bug
>          Components: Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>             Fix For: 1.2
>
>         Attachments: long-opt-name-arg-separator.patch, use-equal-sign-with-long-opts.patch, use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (CLI-169) Formatting option for long opts

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bourg updated CLI-169:
-------------------------------

         Priority: Minor  (was: Major)
    Fix Version/s:     (was: 1.2)
                   1.3
       Issue Type: Improvement  (was: Bug)
          Summary: Formatting option for long opts  (was: HelpFormatter ignores Option's value separator)

> Formatting option for long opts
> -------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Improvement
>          Components: Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>            Priority: Minor
>             Fix For: 1.3
>
>         Attachments: long-opt-name-arg-separator.patch, use-equal-sign-with-long-opts.patch, use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (CLI-169) Formatting option for long opts

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12878962#action_12878962 ]

Emmanuel Bourg commented on CLI-169:
------------------------------------

My suggestion to use a boolean flag is too restrictive. An extra parameter on the formatter specifying the separator is more flexible. No validation will be performed, it'll be up to the user to pick a separator supported by the parser.


> Formatting option for long opts
> -------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Improvement
>          Components: Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>            Priority: Minor
>             Fix For: 1.3
>
>         Attachments: long-opt-name-arg-separator.patch, use-equal-sign-with-long-opts.patch, use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (CLI-169) Formatting option for long opts

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/CLI-169?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bourg resolved CLI-169.
--------------------------------

    Resolution: Fixed

Fix committed. The separator can now be changed by calling setLongOptSeparator() on the formatter.

> Formatting option for long opts
> -------------------------------
>
>                 Key: CLI-169
>                 URL: https://issues.apache.org/jira/browse/CLI-169
>             Project: Commons CLI
>          Issue Type: Improvement
>          Components: Help formatter
>    Affects Versions: 1.2
>            Reporter: J. Lewis Muir
>            Priority: Minor
>             Fix For: 1.3
>
>         Attachments: long-opt-name-arg-separator.patch, use-equal-sign-with-long-opts.patch, use-value-separator-in-help-formatter.patch
>
>   Original Estimate: 0.5h
>  Remaining Estimate: 0.5h
>
> The HelpFormatter always renders a space between the option name and value even if the option has a value separator that is not a space.  For example, this option:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> is rendered like this:
> {noformat}
> -B,--bsize <SIZE>  block size in bytes
> {noformat}
> But I would expect it to be rendered like this:
> {noformat}
> -B,--bsize=<SIZE>  block size in bytes
> {noformat}
> For the automatically generated usage message, a similar problem exists.  I changed it to try to use the value separator when rendering the option with the short name only if there's no long name.  If there's no short name, it always tries to use the value separator with the long name rendering.
> For example, consider this option containing a short name and a specified value separator:
> {code}
> Option option = new Option("B", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> The automatically generated usage message with my changes would look like this:
> {noformat}
> usage: app [-B=<SIZE>]
> {noformat}
> If the same option included a long name too:
> {code}
> Option option = new Option("B", "bsize", true, "block size in bytes");
> option.setArgName("SIZE");
> option.setValueSeparator('=');
> {code}
> with my changes the value separator is assumed to be meant for use with the long name.  The short option rendering in the usage message will not try to use the value separator and will render the usage message like this:
> {noformat}
> usage: app [-B <SIZE>]
> {noformat}
> Attached is a patch for these fixes with test cases.  The patch is against [http://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x].

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.