Skip to content

Latest commit

 

History

41 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cargo-q

Crates.io MSRV Apache 2.0

Run multiple Cargo commands sequentially or in parallel.

usage

Installation

cargo install cargo-q --locked

Features

  • Run multiple Cargo commands sequentially, separated by spaces
  • Stop at the first failure and exit with that command's code
  • Parallel execution (experimental)
  • Verbose mode

Usage

Run a Single Command

cargo q check

Run Multiple Commands

cargo q check test      # Runs check, then test

Commands with Arguments

Tokens starting with - are arguments to the preceding command:

cargo q build -r test --no-run

Quote a command whose argument does not start with -:

cargo q "test --features feature1"

Any other bare token must name a cargo subcommand; cargo-q errors instead of guessing:

cargo q build --features feature1
# error: 'feature1' is not a cargo subcommand
# help: quote the whole command: cargo q "build --features feature1"
# help: or attach the value: cargo q build --features=feature1

The hints echo the command you typed, so the fix can be pasted back:

cargo q run -p oven
# error: 'oven' is not a cargo subcommand
# help: quote the whole command: cargo q "run -p oven"
# help: or attach the value: cargo q run -p=oven

A bare token that is a subcommand still starts a new command, even when you meant it as an argument. Feature names like test and aliases like t collide this way:

cargo q build --features test    # runs `cargo build --features` and `cargo test`
cargo q "build --features test"  # passes test as the feature
cargo q build --features=test    # same

Dry Run

-n/--dry-run shows how a command line was split, without running anything:

cargo q -n build --features test
# 2 command(s), sequentially:
#   cargo build --features
#   cargo test

Stopping on Failure

cargo-q stops at the first failure, like && in a shell, and exits with that command's own code:

cargo q clippy test    # clippy fails -> test is skipped

-k/--keep-going runs the whole list anyway; the exit code still reports the first failure:

cargo q -k fmt clippy test

In parallel mode only queued commands are skipped — one already running is left to finish.

Parallel Execution (Experimental)

Warning

Parallel execution may not be any faster. Commands like cargo check, cargo build, and cargo test share the same target directory and lock it, so they block each other instead of overlapping.

cargo q -p check test            # Run both commands in parallel
cargo q --parallel check test    # Same as above

Verbose Output

cargo q -v check test            # Show each command's output as it runs
cargo q --verbose check test     # Same as above

--verbose is sequential only. With --parallel, cargo-q warns and runs quietly.

Exit Codes

Code Meaning
0 all commands succeeded
child's code the first command that failed (e.g. 101 from cargo test)
128 + signal that command was killed by a signal
130 interrupted with Ctrl-C

License

Licensed under Apache-2.0 license (LICENSE or http://opensource.org/licenses/Apache-2.0)

About

Run multiple Cargo commands sequentially or in parallel.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages