Add stderr, stdin, and stdout support for Dry::CLI#151
Conversation
ef66718 to
075a7c6
Compare
|
Per my comments here (#150 (comment)), this is a change that I think is worth breaking API compatibility over, and releasing as 2.0 if needed. Why is it breaking compatibility? Previously Dry::CLI made no claim over the structure of a command's I think this is a good change because it sets the expectation with users that they should use the streams that are given to them, rather than handle IO themselves. This ensures we're using the same streams as given to This arrangement matches what we already do internally within Hanami::CLI::Command, which is our own primary in-ecosystem consumer of Dry CLI. @flash-gordon @cllns @alassek — what do you think about this? Worth the change, in your opinion? And do you actually consider it "breaking?" |
| spell_checker = SpellChecker.call(result, arguments) | ||
| err.puts spell_checker if spell_checker | ||
| stderr.puts spell_checker if spell_checker | ||
| puts |
There was a problem hiding this comment.
@timriley is this a bug? Should this be stderr.puts and if so would you like me to fix it in this PR?
Introduce `stderr`, `stdin`, and `stdout` streams to `Dry::CLI` and its components to better handle I/O. This allows commands to utilize specific input/output streams, improving flexibility and testability. Refactor existing methods to use the new stream parameters consistently.
075a7c6 to
5444454
Compare
There was a problem hiding this comment.
This looks good to me, @aaronmallen, but it looks like we're missing some testing? These args/attributes are becoming an important part of our public API for commands, but we don't have any new tests to go along with their introduction here. Do you think you could add some in? Thanks!
Introduce
stderr,stdin, andstdoutstreams toDry::CLIand its components to better handle I/O. This allows commands to utilize specific input/output streams, improving flexibility and testability. Refactor existing methods to use the new stream parameters consistently.As an alternative to #150
cc @timriley