Cmder implements builder functionality wrapping os/exec for easily constructing shell commands. The initial intended use for this package was simple scripting with Mage, but there is nothing that should stop it from being used in other implementations.
Heavily inspired by Mage's own sh library and many more great projects who have come before.
Examples can be found in the _examples/magefile.go
Magefile.
Run the following to execute any of the example targets from the above Magefile.
cd _examples
mage -l
Additionally many of the tests can provide some example usage.
Cmder logs all commands being run, using the Logger
method, which implements the Logger
interface:
type Logger interface {
// Log inserts a log entry. Arguments may be handled in the manner
// of fmt.Print, but the underlying logger may also decide to handle
// them differently.
Log(v ...interface{})
// Logf inserts a log entry. Arguments are handled in the manner of
// fmt.Printf.
Logf(format string, v ...interface{})
}
By default (if none specified with the Cmder.Logger()
method) the built-in logger will be used. See Additional log.Logger*
variables for configuration
options.
Color is disabled by default, but can be enabled by setting either MAGEFILE_ENABLE_COLOR
or
CMDER_ENABLE_COLOR
environment variables to true.
The default logger will check the terminal width and if the command to be printed is wider than the terminal width, it will be broken up into multiple lines, similar to a shell command represented on multiple lines.
See CONTRIBUTING.md. Contributors should follow the Go Community Code of Conduct .
Requires:
Run:
mage check