Skip to main content

Overview

The following options are available for all moon commands.

  • --cache <mode> - The mode for cache operations.
  • --color - Force colored output for moon (not tasks).
  • --help - Display the help menu for the current command.
  • --log <level> - The lowest log level to output.
  • --logFile <file> - Write logs to the defined file.
  • --version - Display the version of the CLI.

Global options must be passed after the moon binary and before the command.

$ moon --log error <command>

Caching

We provide a powerful caching layer, but sometimes you need to debug failing or broken tasks, and this cache may get in the way. To circumvent this, we support the --cache global option, or the MOON_CACHE environment variable, both of which accept one of the following values.

  • off - Turn off caching entirely. Every task will run fresh, including dependency installs.
  • read - Read existing items from the cache, but do not write to them.
  • write (default) - Read and write items to the cache.
$ moon --cache off run app:build
# Or
$ MOON_CACHE=off moon run app:build

Colors

Colored output is a complicated subject, with differing implementations and standards across tooling and operating systems. moon aims to normalize this as much as possible, by doing the following:

  • By default, moon colors are inherited from your terminal settings (TERM and COLORTERM environment variables).
  • Colors can be force enabled by passing the --color option (preferred), or MOON_COLOR or FORCE_COLOR environment variables.
$ moon --color run app:build
# Or
$ MOON_COLOR=2 moon run app:build

When forcing colors with MOON_COLOR or FORCE_COLOR, you may set it to one of the following numerical values for the desired level of color support. This is automatically inferred if you use --color.

  • 0 - No colors
  • 1 - 16 colors (standard terminal colors)
  • 2 - 256 colors
  • 3 - 16 million colors (truecolor)

Piped output

When tasks (child processes) are piped, colors and ANSI escape sequences are lost, since the target is not a TTY and we do not implement a PTY. This is a common pattern this is quite annoying. However, many tools and CLIs support a --color option to work around this limitation and to always force colors, even when not a TTY.

To mitigate this problem as a whole, and to avoid requiring --color for every task, moon supports the runner.inheritColorsForPipedTasks configuration setting. When enabled, all piped child processes will inherit the color settings of the currently running terminal.

Debugging

At this point in time, moon provides no debugging utilities besides logging with the debug/trace levels.

Logging

By default, moon aims to output as little as possible, as we want to preserve the original output of the command's being ran, excluding warnings and errors. This is managed through log levels, which can be defined with the --log global option, or the MOON_LOG environment level. The following levels are supported, in priority order.

  • off - Turn off logging entirely.
  • error - Only show error logs.
  • warn - Only show warning logs and above.
  • info (default) - Only show info logs and above.
  • debug - Only show debug logs and above.
  • trace - Show all logs, including network requests and child processes.
$ moon --log trace run app:build
# Or
$ MOON_LOG=trace moon run app:build

Outputting logs to a file

moon can dump the logs from a command to a file using the --logFile option, or the MOON_LOG_FILE environment variable. The dumped logs will respect the --log option and filter the logs piped to the output file.

$ moon --logFile=output.log run app:build
# Or
$ MOON_LOG_FILE=output.log moon run app:build