Skip to content

Commit b6b7f8e

Browse files
authored
release: 0.2.0 (#8)
* feat: remove ; and & separators * doc: update document * chore: fix clippy errors * chore: use Cargo instead of cargo * chore: update CHANGELOG
1 parent 47a1bef commit b6b7f8e

11 files changed

+101
-251
lines changed

CHANGELOG.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Changelog
2+
3+
## [0.2.0] - 2025-03-08
4+
5+
### Changed
6+
- Simplified command parsing by removing `;` and `&` separators
7+
- Commands are now only separated by spaces
8+
- For commands with arguments, you need to quote the entire command
9+
- Updated documentation to reflect the new simplified syntax
10+
- Removed dependent execution strategy (previously used with `&` separator)
11+
- Improved parser to directly use parsed CLI arguments instead of re-parsing a command string
12+
13+
### Fixed
14+
- Improved handling of commands with arguments
15+
16+
## [0.1.6] - 2025-03-07
17+
18+
### Added
19+
- Initial release
20+
- Support for running multiple commands sequentially or in parallel
21+
- Support for different separators (space, `;`, `&`)
22+
- Verbose mode for detailed output

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "cargo-q"
3-
version = "0.1.6"
3+
version = "0.2.0"
44
edition = "2021"
5-
description = "A cargo subcommand for running multiple cargo commands in a time"
5+
description = "A Cargo subcommand for running multiple Cargo commands sequentially or in parallel."
66
keywords = ["cargo", "subcommand", "plugin"]
77
categories = ["command-line-utilities", "development-tools::cargo-plugins"]
88
license = "Apache-2.0"

README.md

+14-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# cargo-q
22

3-
A Cargo subcommand that allows running multiple Cargo commands in a time.
3+
A Cargo subcommand for running multiple Cargo commands sequentially or in parallel.
44

55
## Installation
66

@@ -11,11 +11,8 @@ cargo install cargo-q
1111
## Features
1212

1313
- Run multiple Cargo commands sequentially
14-
- Use different separators for command execution:
15-
- Space: Run commands sequentially (independent execution)
16-
- `;`: Run independent commands sequentially
17-
- `&`: Run commands with dependencies (each command depends on previous command's success)
18-
- Support parallel execution for independent commands
14+
- Commands are separated by spaces
15+
- Support parallel execution for commands
1916
- Verbose mode for detailed output
2017

2118
## Usage
@@ -28,39 +25,32 @@ cargo q check
2825

2926
### Run Multiple Commands
3027

31-
#### Sequential Execution (Space Separator)
3228
```bash
33-
# Run commands sequentially and independently
34-
cargo q "check test" # Runs check, then test
35-
cargo q 'check test' # Single and double quotes both work
29+
# Run commands sequentially
30+
cargo q check test # Runs check, then test
3631
```
3732

38-
#### Independent Commands (`;` Separator)
39-
```bash
40-
# Run commands sequentially and independently
41-
cargo q "test --features feature1 ; run" # Commands with parameters need ; separator
42-
```
33+
### Commands with Arguments
4334

44-
#### Dependent Commands (`&` Separator)
4535
```bash
46-
# Run commands with explicit dependencies
47-
cargo q "check & test & run" # Each command runs only if previous command succeeds
48-
cargo q "check&test&run" # Spaces around & are optional
36+
# For commands with arguments
37+
cargo q "test --no-run" # Run test with --no-run flag
38+
cargo q "test --features feature1" # Use quotes for complex arguments
4939
```
5040

5141
### Parallel Execution
5242

5343
```bash
54-
# Run independent commands in parallel
55-
cargo q -p "build -r; build" # Run both commands in parallel
56-
cargo q --parallel "check; test" # Same as above
44+
# Run commands in parallel
45+
cargo q -p check test # Run both commands in parallel
46+
cargo q --parallel check test # Same as above
5747
```
5848

5949
### Verbose Output
6050

6151
```bash
62-
cargo q -v "check test" # Show detailed output
63-
cargo q --verbose "check test" # Same as above
52+
cargo q -v check test # Show detailed output
53+
cargo q --verbose check test # Same as above
6454
```
6555

6656
## License

src/cli.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ use clap::Parser;
88
pub struct Cli {
99
/// Commands to execute
1010
///
11-
/// Supports multiple separators:
11+
/// Commands are separated by spaces:
1212
///
13-
/// space: Independent commands (e.g., "check test")
13+
/// e.g., check test run
1414
///
15-
/// ; : Independent commands with args (e.g., "test --features f1 ; run")
15+
/// Note: For commands with arguments, you need to quote the entire command:
1616
///
17-
/// & : Dependent commands (e.g., "check & test & run")
18-
pub command_string: String,
17+
/// e.g., "test --features f1" "run --release"
18+
#[arg(required = true, allow_hyphen_values = true)]
19+
pub commands: Vec<String>,
1920

2021
/// Run commands in verbose mode
2122
///
@@ -25,7 +26,7 @@ pub struct Cli {
2526

2627
/// Run commands in parallel
2728
///
28-
/// Only works with independent commands (space or ; separator)
29+
/// Runs all commands in parallel instead of sequentially
2930
#[arg(short, long)]
3031
pub parallel: bool,
3132
}
@@ -34,8 +35,6 @@ impl Cli {
3435
pub fn parse() -> Self {
3536
// Skip the all arguments which are "q" for cargo subcommands
3637
let args = std::env::args()
37-
.collect::<Vec<_>>()
38-
.into_iter()
3938
.filter(|arg| arg != "q")
4039
.collect::<Vec<_>>();
4140

src/executor.rs

+6-23
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,26 @@
11
use crate::routine::Routine;
2-
use crate::strategy::{
3-
DependentStrategy, ExecutionStrategy, ParallelStrategy, SequentialStrategy, Strategy,
4-
};
5-
use std::io::{self, Error, ErrorKind};
2+
use crate::strategy::{ExecutionStrategy, ParallelStrategy, SequentialStrategy};
3+
use std::io;
64

75
pub(crate) struct Executor {
86
pub(super) parallel: bool,
97
pub(super) verbose: bool,
10-
pub(super) strategy: Strategy,
118
pub(super) routines: Vec<Routine>,
129
}
1310

1411
impl Executor {
15-
pub fn new(parallel: bool, verbose: bool, routines: Vec<Routine>, strategy: Strategy) -> Self {
12+
pub fn new(parallel: bool, verbose: bool, routines: Vec<Routine>) -> Self {
1613
Executor {
1714
parallel,
1815
verbose,
19-
strategy,
2016
routines,
2117
}
2218
}
2319

2420
pub fn execute(&self) -> io::Result<()> {
25-
let strategy: Box<dyn ExecutionStrategy> = match (self.parallel, self.strategy) {
26-
(true, Strategy::Independent) => Box::new(ParallelStrategy),
27-
(true, _) => {
28-
return Err(Error::new(
29-
ErrorKind::InvalidInput,
30-
"Parallel execution only supports independent commands now",
31-
))
32-
}
33-
(false, Strategy::Independent) => Box::new(SequentialStrategy),
34-
(false, Strategy::Dependent) => Box::new(DependentStrategy),
35-
(false, Strategy::Pipe) => {
36-
return Err(Error::new(
37-
ErrorKind::Unsupported,
38-
"Pipe strategy not implemented yet",
39-
))
40-
}
21+
let strategy: Box<dyn ExecutionStrategy> = match self.parallel {
22+
true => Box::new(ParallelStrategy),
23+
false => Box::new(SequentialStrategy),
4124
};
4225

4326
strategy.execute(&self.routines, self.verbose)

src/main.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ use parser::Parser;
1111

1212
fn main() {
1313
let cli = Cli::parse();
14-
let parser = Parser::new();
15-
let executor = parser.parse(&cli.command_string, cli.parallel, cli.verbose);
16-
14+
let executor = Parser.parse(&cli.commands, cli.parallel, cli.verbose);
1715
if let Err(e) = executor.execute() {
1816
eprintln!("{}", e);
1917
std::process::exit(1);

0 commit comments

Comments
 (0)