We break down why, in a CLI, it is better not to write directly to
os.Stdout and not to read from
os.Stdin, but to inject dependencies via
io.Writer/
io.Reader. We design a command contract
Run(...) that returns an exit code, keep
main thin, separate stdout/stderr, and configure
flag.FlagSet output via
SetOutput. As a result, the CLI becomes predictable and easy to test without “intercepting” global I/O.