Module execute

Module execute 

Source
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:

  1. Parses the --cmd parameter to determine command type
  2. Detects all workspace packages via monorepo detector
  3. Filters packages if --filter-package is specified
  4. For npm scripts, validates the script exists in each package.json
  5. Executes commands sequentially or in parallel based on --parallel flag
  6. Streams output in real-time to stdout
  7. 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.