Skip to content

kevgo/conc

Repository files navigation

conc

Conc runs multiple CLI commands concurrently, returns the first non-zero exit code it encounters, and filters command output.

It is intended for development scripts and CI pipelines.

linux windows

usage

Pass the commands to execute as strings.

conc "echo one" "echo two" "echo three"

This executes the following commands concurrently:

  • echo one
  • echo two
  • echo three

For readability, you can put each command on its own line:

conc "echo one" \
     "echo two" \
     "echo three"

Commands are executed inside a shell (sh on Linux/macOS, cmd.exe on Windows), so you can use shell features:

conc "echo one && echo two | grep on > file"

output verbosity

When running linters, tests, or compilers, you often only care whether everything passed and want detailed output only for problems. The --show flag controls how much output conc prints:

  • --show=all (default) prints the name and output of every command after it finishes
  • --show=names prints the name of every command after it finishes, and only the output of failed commands
  • --show=failed prints only the name and output of failed commands

Flags for conc must appear before the first command to execute:

conc --show=failed "echo one" "echo two"

colors

Conc emits ANSI colors when STDOUT and STDERR are connected to a TTY. You can override this behavior using environment variables:

  • CLICOLOR_FORCE=1 always enables color output, even when not connected to a TTY
  • NO_COLOR=1 disables colors

error on output

Some tools report findings via STDOUT or STDERR but still exit with a success code. The --error-on-output flag treats any output as failure.

conc --error-on-output "echo foo"

This exits with status code 1 because the command produced output.

If you want this behavior only for specific commands, wrap them in a nested conc call. For example, to enable error on output only for command 2:

conc "command 1" \
     "conc --error-on-output 'command 2'" \
     "command 3"

alternatives

  • gnu parallel: also runs commands concurrently, but does not reliably propagate a single, meaningful exit code suitable for scripts

About

executes CLI applications concurrently and returns the proper exit code

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors