Design issue: Clikt uses Inheritance instead of Composition
See original GitHub issueI think there is a design issue in Clikt, It tries todo too much.
Ideally I just want to have an argument parser, and use that where-ever its needed. (Command line tools for example).
But Clikt really requires you to use inheritance and not composition. Composition allows for plug and play of the argument parser, like https://github.com/Kotlin/kotlinx-cli does.
I actually tried using Clikt initially, but found issues where clikt already defines the main
function so I cannot use it directly.
Next to that, it requires subclassing, so i cant use clikt in a class that already is subclassing an abstract class.
All in all, this makes clikt less usable/pluggable. It would be nice if clikt could be use without subclassing. And just as an argument parser tool, not as a command runner tool.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top GitHub Comments
I recently added Clikt just for command line parsing to an existing small app, which was surprisingly easy, although the design seems to target a more involved usage. I just created an “Options” object that extended NoOpCliktCommand, so calling main(argv) did nothing more than parsing the parameters, and the results could then easily be queried on the Option’s properties.
So, as it turned out, the current design is quite well prepared for a “pluggable” usage.
@tjerkw yes, an example would be helpful. I’m not sure what you mean when you say you want it to me pluggable.