remkop / picocli

Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
https://picocli.info
Apache License 2.0
4.93k stars 424 forks source link

Access to ArgSpec and OptionSpec setter/getter fields and methods #2325

Open pvlasov opened 4 months ago

pvlasov commented 4 months ago

Nasdanika CLI operates on top of Picocli. One of its features is generation of HTML documentation site and support of extended documentation. Sample site without extended documentation.

Currently this functionality works with CommandSpec by accessing user object. To extend it to ArgSpec/OptionSpec it is necessary to be able to access underlying fields/methods.

This commit introduces IReflector interface which provides access to AnnotatedElement (Method/Field). This interface is implemented by FieldBinding and Method Binding.

I hope that this modification is in alignment with the Picocli philosophy and will be accepted! Please let me know whether any further action is required from me, e.g. creation of a pull request!

remkop commented 3 months ago

Okay, we can do this. Can we call the interface IAnnotatedElementProvider?

pvlasov commented 3 months ago

Great! I've renamed IReflector to IAnnotatedElementProvider: https://github.com/remkop/picocli/compare/main...Nasdanika:picocli:main.

Please let me know if you need anything else!

remkop commented 3 months ago

Can you provide a pull request with tests please?

pvlasov commented 3 months ago

I've created a pull request - https://github.com/remkop/picocli/pull/2328. It builds successfully in my local environment, the merge request status is "Review required".