New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose BuiltinHelpFormatter to allow customization of option rendering #68

Closed
snicoll opened this Issue Oct 29, 2014 · 9 comments

Comments

Projects
None yet
2 participants
@snicoll

snicoll commented Oct 29, 2014

Currently a short option is detected when it is represented by a single letter. All other options are considered as long options (i.e. with the double hyphen notation).

There are numerous cases where it's legit to have a short options with two characters (-bv for instance). I tried to add a support for this in Spring Boot and I don't see anything that would prevent that. The reason I am asking here is that the help has no notion of this and BuiltinHelpFormatter is package protected so I can't really tune that except if I copy/paste the whole class.

It would be nice if the logic that define if it's a short option (currently option.length() ==1) would be configurable.

@pholser

This comment has been minimized.

Show comment
Hide comment
@pholser

pholser Oct 29, 2014

Collaborator

Hi @snicoll -- thanks for your interest!

JOpt Simple recognizes long options specified with single - on command lines. Are you asking for a way to format help in such a way that long options are shown with a single -? If so, one possibility might be to relax the private-ness of many of the methods of BuiltinHelpFormatter, and document that class a little better (maybe even renaming it) with the idea that if you want the basic flow of that class but finer-grained control over specific steps, you'll be able to subclass and override the bits you want.

How does that sound?

Collaborator

pholser commented Oct 29, 2014

Hi @snicoll -- thanks for your interest!

JOpt Simple recognizes long options specified with single - on command lines. Are you asking for a way to format help in such a way that long options are shown with a single -? If so, one possibility might be to relax the private-ness of many of the methods of BuiltinHelpFormatter, and document that class a little better (maybe even renaming it) with the idea that if you want the basic flow of that class but finer-grained control over specific steps, you'll be able to subclass and override the bits you want.

How does that sound?

@snicoll

This comment has been minimized.

Show comment
Hide comment
@snicoll

snicoll Oct 29, 2014

Thanks for the reply.

Even if JOpt Simple recognizes those we want a help page that looks like what regular command line tools do. Since you seem to want things to be very permissive, I guess what I need is to be able to extend from BuiltinHelpFormatter and override a method that determines how to format a given option.

snicoll commented Oct 29, 2014

Thanks for the reply.

Even if JOpt Simple recognizes those we want a help page that looks like what regular command line tools do. Since you seem to want things to be very permissive, I guess what I need is to be able to extend from BuiltinHelpFormatter and override a method that determines how to format a given option.

@pholser

This comment has been minimized.

Show comment
Hide comment
@pholser

pholser Oct 29, 2014

Collaborator

@snicoll Sounds good. I'll undertake exposing enough of BuiltinHelpFormatter to allow for customization.

Collaborator

pholser commented Oct 29, 2014

@snicoll Sounds good. I'll undertake exposing enough of BuiltinHelpFormatter to allow for customization.

@pholser pholser changed the title from Explicit support for short options to Expose BuiltinHelpFormatter to allow customization of option rendering Jan 14, 2015

pholser added a commit that referenced this issue Jan 14, 2015

For #68, begin to expose enough methods on BuiltinHelpFormatter...
...to allow for subclasses to tweak behavior and rendering as they see fit.
@pholser

This comment has been minimized.

Show comment
Hide comment
@pholser

pholser Jan 14, 2015

Collaborator

@snicoll Branch issues/68/expose-builtin-help-formatter has an altered version of BuiltinHelpFormatter that makes a number of formatting helper methods protected instead of private. It also introduces a method optionLeader(String) that decides what to prepend an option with. By default, it decides between '-' and '--' depending on the length of the given option indicator.

If you would, checkout this branch, build, and see whether this suits your needs. If so, I'll invest some more time in Javadoc'ing the class, especially being careful to document what behaviors the default impls guarantee.

Thanks!

Collaborator

pholser commented Jan 14, 2015

@snicoll Branch issues/68/expose-builtin-help-formatter has an altered version of BuiltinHelpFormatter that makes a number of formatting helper methods protected instead of private. It also introduces a method optionLeader(String) that decides what to prepend an option with. By default, it decides between '-' and '--' depending on the length of the given option indicator.

If you would, checkout this branch, build, and see whether this suits your needs. If so, I'll invest some more time in Javadoc'ing the class, especially being careful to document what behaviors the default impls guarantee.

Thanks!

@snicoll

This comment has been minimized.

Show comment
Hide comment
@snicoll

snicoll Jan 14, 2015

Awesome, will do tomorrow

snicoll commented Jan 14, 2015

Awesome, will do tomorrow

@snicoll

This comment has been minimized.

Show comment
Hide comment
@snicoll

snicoll Jan 16, 2015

@pholser I had a look to the changes and optionLeader is doing exactly what I want. Thanks!

snicoll commented Jan 16, 2015

@pholser I had a look to the changes and optionLeader is doing exactly what I want. Thanks!

@pholser

This comment has been minimized.

Show comment
Hide comment
@pholser

pholser Jan 16, 2015

Collaborator

@snicoll Excellent. I'll move forward with documenting the behaviors of the exposed methods. Expect to see this stuff in a 4.9 snapshot soon. I appreciate your feedback!

Collaborator

pholser commented Jan 16, 2015

@snicoll Excellent. I'll move forward with documenting the behaviors of the exposed methods. Expect to see this stuff in a 4.9 snapshot soon. I appreciate your feedback!

@snicoll

This comment has been minimized.

Show comment
Hide comment
@snicoll

snicoll commented Jan 16, 2015

Awesome!

@pholser

This comment has been minimized.

Show comment
Hide comment
@pholser

pholser Jan 29, 2015

Collaborator

Merged into branch 4.x.

Collaborator

pholser commented Jan 29, 2015

Merged into branch 4.x.

@pholser pholser closed this Jan 29, 2015

pholser added a commit that referenced this issue Feb 1, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment