jawher / mow.cli

A versatile library for building CLI applications in Go
MIT License
872 stars 55 forks source link

Publish `Stderr` to allow testing help #130

Closed dnagir closed 3 months ago

dnagir commented 1 year ago

It is useful to test the help output for the non-trivial CLIs and in the environment where an example outputs are desired.

Before this, testing for help required resorting to os/exec.

After this, the consumer test can swap the cli.Stderr for testing purposes while not affecting any other details of the mow.cli.

The stdOut is not published as it is only used internally for testing and has no impact on consumers as mow.cli never prints to STDOUT.

NOTE: alternative implementation exists but has a larger "blast radius".