Improve DX when using printer and config#76
Improve DX when using printer and config#76WendellAdriel merged 5 commits intominicli:mainfrom WendellAdriel:command-dx-improvement
Conversation
JustSteveKing
left a comment
There was a problem hiding this comment.
I like this idea and is something I have been thinking about as well. However I initially thought about just adding a proxy method on the CommandController itself instead of a whole other class with all the additional methods.
|
@JustSteveKing I thought about that but I worked on a trait to have it working on the CommandController and on the App instance as well. But if you think this is too much I can rework the changes. Just let me know what you feel it’s better |
I think what you have done works well, but every new printer command we add we will have to do it twice so that it is accessible |
|
@JustSteveKing true. I have something in mind, I’ll make some changes tomorrow and update the PR |
|
@JustSteveKing I updated how to handle the proxy for the output handler methods, check if this is better now. |
|
@JustSteveKing after the DI container changes, what should be the approach for this so I can update my PR? |
This will be interesting actually! I think it needs discussion more than anything. The way the current Minicli application works is very anti-di so we need to figure out what DO stuff we want to use |
But should I change anything now or should we merge this to get the DX improvements and work on a refactor in a new PR with other DI stuff? |
Why
Currently, when we need to print something to the terminal, we need to use this approach:
Also, for interacting with the config in classes extending the
CommandControllerwe need to use this approach:It's not bad, but it's also not the best DX.
Solution
I created a
PrinterProxytrait that I set theAppandCommandControllerclasses to use. With this, now we can simplify how we print something to the terminal:I also created a config property in the
CommandControllerso when we need to interact with the config we can use this approach:Additional Work
If this get's merged, I'll work on additional PRs for the minicli/application to use this approach and also a new PR to the docs to update the examples to use this approach as well.