Expand description
Workspace execute command implementation.
This module implements the workspace execute command which runs commands
across workspace packages with optional filtering and parallel execution.
§What
Provides the execute_execute function that:
- Parses command type (npm script or system command)
- Detects workspace packages
- Applies package filtering if specified
- Validates npm scripts exist before execution
- Executes commands with real-time streaming output
- Supports sequential (default) or parallel execution
- Reports execution summary with success/failure counts
§How
The command flow:
- Parses the
--cmdparameter to determine command type - Detects all workspace packages via monorepo detector
- Filters packages if
--filter-packageis specified - For npm scripts, validates the script exists in each package.json
- Executes commands sequentially or in parallel based on
--parallelflag - Streams output in real-time to stdout
- Collects results and displays summary
§Why
Cross-package command execution is essential for:
- Running tests, linting, or builds across all packages
- CI/CD pipelines that need consistent command execution
- Development workflows with monorepo tooling
- Scripting and automation with filtered package execution
§Examples
use sublime_cli_tools::commands::execute::execute_execute;
use sublime_cli_tools::cli::commands::ExecuteArgs;
use sublime_cli_tools::output::{Output, OutputFormat};
use std::io;
use std::path::Path;
let args = ExecuteArgs {
cmd: "npm:lint".to_string(),
filter_package: None,
affected: false,
since: None,
until: None,
branch: None,
parallel: false,
args: vec![],
};
let output = Output::new(OutputFormat::Human, io::stdout(), false);
execute_execute(&args, &output, Path::new(".")).await?;Functions§
- execute_
execute - Execute the workspace execute command.