Skip to content
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

Why is TermUi.echo(..) deprecated #366

Closed
alzamon opened this issue Jul 18, 2022 · 5 comments
Closed

Why is TermUi.echo(..) deprecated #366

alzamon opened this issue Jul 18, 2022 · 5 comments

Comments

@alzamon
Copy link

alzamon commented Jul 18, 2022

TermUi.echo(..) is @deprecated, but all the suggested alternative do is call the very same deprecated method. What is the reasoning here?

I am very tempted to use the @deprecated TermUi.echo(..) method because i want to extract logic to helper functions to hide details from my implemented CliktCommands.

An alternative could be to create helper-methods that are extension functions of CliktCommand, but since CliktCommand.echo(..) is protected that is not possible.

@ajalt
Copy link
Owner

ajalt commented Jul 21, 2022

See #344 for discussion, but the summary is that it was that it was confusing to offer multiple ways to do the same thing. Additionally, TermUi.echo uses a global console instance which can lead to surprises when used at the same time as CliktCommand.echo. In the 4.0 branch, mordant handles the output, so there's no more global console to use.

Can you provide more information on what you're trying to do with your helper functions? Maybe we can come up with a design that fits that use case without the downsides of the current TermUi

@alzamon
Copy link
Author

alzamon commented Jul 21, 2022

Thanks. I had a feeling there was something subtle I was missing.

I'm making a CLI tool for managing versions for other cli-tools. Sample usage application-manager install kubectl --version 1.23.0 or application-manager list-versions trivy.

I would have helper file for instance GithubHelper for downloading binaries from release pages on github and was hoping to echo relevant info to stdout in helper methods.

@ajalt
Copy link
Owner

ajalt commented Jul 21, 2022

How about passing in the console or command as a parameter (or extension) to your helper methods? Then the helpers would still use the right console instance rather than the global one.

@alzamon
Copy link
Author

alzamon commented Jul 21, 2022

Yes. It is a possibility. I solved by a callback parameter. But felt it introduced unneccecary complexity.

Anyway. I feel I understand better now and can close the issue if you want.

@ajalt
Copy link
Owner

ajalt commented Jul 21, 2022

Alright. Thanks for the feedback!

@ajalt ajalt closed this as completed Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants