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

Accessing to a parser's recognizedOptions not only for generating help messages #38

Closed
aneveux opened this Issue Oct 29, 2013 · 5 comments

Comments

Projects
None yet
2 participants
@aneveux
Contributor

aneveux commented Oct 29, 2013

Hello,

Currently using JOpt-Simple on a project for my company, I'm facing a need which is mandatory for my coworkers. Actually, I need to be able, from a particular parser object, to get the specifications of all the recognized options.

I saw that it's possible to have this information from the printHelpOn(Writer) method, which allows to use the private final AbbreviationMap<AbstractOptionSpec<?>> recognizedOptions; field in order to get all the available parameters, their types, etc. But I need it for something else than help messages.

Do you have in mind an existing way of getting this field from a parser? If no, do you think it could be possible to release a new version with a getter for this field? (which I can provide, for sure, it's only a few lines for a getter). But I'd like to ensure that it's ok on your side.

If it's ok, do you have an idea of the time needed to build a new release including this feature?

Thanks a lot for your help on that topic ;)

Best regards,

@pholser

This comment has been minimized.

Show comment
Hide comment
@pholser

pholser Oct 29, 2013

Collaborator

Sounds like a reasonable feature.

Would it suffice to expose this as a Map<String, OptionSpec<?>>, in the vein of AbbreviationMap.toJavaUtilMap()? Maybe call it OptionParser.recognizedOptions(), returning such a Map? I consider AbbreviationMap more of an implementation detail to support abbreviations of options, and never intended for it to become part of the public API.

I'm thinking that such a method should produce a Map only of the full options, with no abbreviations.

Would you like to have a go at a pull request? Once merged, I can push a snapshot build to Sonatype central, and it would be available then for you to test and try out with your colleagues.

Thanks again for your interest!

Collaborator

pholser commented Oct 29, 2013

Sounds like a reasonable feature.

Would it suffice to expose this as a Map<String, OptionSpec<?>>, in the vein of AbbreviationMap.toJavaUtilMap()? Maybe call it OptionParser.recognizedOptions(), returning such a Map? I consider AbbreviationMap more of an implementation detail to support abbreviations of options, and never intended for it to become part of the public API.

I'm thinking that such a method should produce a Map only of the full options, with no abbreviations.

Would you like to have a go at a pull request? Once merged, I can push a snapshot build to Sonatype central, and it would be available then for you to test and try out with your colleagues.

Thanks again for your interest!

@aneveux

This comment has been minimized.

Show comment
Hide comment
@aneveux

aneveux Nov 2, 2013

Contributor

Hello :)

Thanks a lot for your feedbacks. I completely agree with your proposition, that would be perfect. I'll try to send a pullrequest as soon as possible ;)

Thanks a lot for your help on that topic, I'll see how to implement something based on your advices ;) I'll keep you in touch ;)

Contributor

aneveux commented Nov 2, 2013

Hello :)

Thanks a lot for your feedbacks. I completely agree with your proposition, that would be perfect. I'll try to send a pullrequest as soon as possible ;)

Thanks a lot for your help on that topic, I'll see how to implement something based on your advices ;) I'll keep you in touch ;)

@aneveux

This comment has been minimized.

Show comment
Hide comment
@aneveux

aneveux Nov 6, 2013

Contributor

Hi @pholser :)

Any news about that topic?

Thanks a lot for your attention ;)

Contributor

aneveux commented Nov 6, 2013

Hi @pholser :)

Any news about that topic?

Thanks a lot for your attention ;)

@pholser pholser closed this in #39 Nov 6, 2013

pholser added a commit that referenced this issue Nov 6, 2013

@pholser

This comment has been minimized.

Show comment
Hide comment
@pholser

pholser Nov 6, 2013

Collaborator

I've merged your pull request. This is in the latest 4.6-SNAPSHOT at https://oss.sonatype.org/content/repositories/snapshots/ -- thanks for contributing!

Collaborator

pholser commented Nov 6, 2013

I've merged your pull request. This is in the latest 4.6-SNAPSHOT at https://oss.sonatype.org/content/repositories/snapshots/ -- thanks for contributing!

@aneveux

This comment has been minimized.

Show comment
Hide comment
@aneveux

aneveux Nov 6, 2013

Contributor

Thanks a lot @pholser ! Glad it looked interesting for you ;)

Contributor

aneveux commented Nov 6, 2013

Thanks a lot @pholser ! Glad it looked interesting for you ;)

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