question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Design issue: Clikt uses Inheritance instead of Composition

See original GitHub issue

I 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:open
  • Created a year ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Caralluincommented, Dec 3, 2022

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.

0reactions
ajaltcommented, Oct 26, 2022

@tjerkw yes, an example would be helpful. I’m not sure what you mean when you say you want it to me pluggable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Composition vs Inheritance | DigitalOcean
Inheritance is the design technique in object-oriented programming to implement is-a relationship between objects. Inheritance in Java is ...
Read more >
Composition vs. Inheritance: How to Choose? - Thoughtworks
Inheritance: a class may inherit - use by default - the fields and methods of its superclass. Inheritance is transitive, so a class...
Read more >
Composition vs Inheritance in C# - Code Maze
Composition and Inheritance are used to create relationships between classes. Inheritance is used for "is-a" while composition for a "has-a"
Read more >
Inheritance and Composition: A Python OOP Guide
Inheritance and composition are two major concepts in object oriented programming that model the relationship between two classes. They drive the design of ......
Read more >
C# Composition vs Inheritance: OOP's greatest dilemma
Does a class need to hold or use parts of an object (class) i.e. does ... You may have already spotted the issue...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found