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

Be able to test the output of cmdr #40

Open
TFCx opened this issue Jan 19, 2020 · 1 comment
Open

Be able to test the output of cmdr #40

TFCx opened this issue Jan 19, 2020 · 1 comment

Comments

@TFCx
Copy link

TFCx commented Jan 19, 2020

I'm doing some unit testing to check if my software produces the correct results. Right now, cmdr uses println!() but it would be cool I could configure the output stream. Would that mean that scopes should store a reference to a "Write" interface and use write!() instead of print!()?
In addition to testing, I think it could also be needed if someone uses cmdr using some TCP stream or if they want to both stdout and log the commands and results produced.

@mendelt
Copy link
Owner

mendelt commented Jan 19, 2020

Sounds good but this will take some more time. I had similar requests when I did a talk about cmdr some months ago. This also fits nicely with your other issue #39. Being able to redirect input is more useful if you can also redirect output.
This will probably be optional, people should still be able to use println! for output in simple use-cases. And I'll have to think about how this fits with some of the other planned features.
I don't really want to go the route of forcing users of the library to store state in their scopes. I might be able to add scope state with the cmdr macro but I'd like to avoid that if I could.
I think the sane way to do this would be to pass in a writer as a parameter to commands that need it. That would be quite a change in the api though.

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