Module remove

Module remove 

Source
Expand description

Changeset remove command implementation.

This module implements the changeset remove command for deleting changesets.

§What

Provides the execute_remove function that:

  • Deletes a specified changeset from the workspace
  • Archives the changeset before deletion for recovery purposes
  • Requires user confirmation by default (unless –force flag is used)
  • Validates that the changeset exists before attempting deletion
  • Provides clear feedback on what was deleted
  • Handles errors gracefully with user-friendly messages

§How

The command flow:

  1. Loads workspace configuration and validates initialization
  2. Creates ChangesetManager to access changeset storage
  3. Verifies the changeset exists
  4. Loads the changeset to display what will be deleted
  5. Prompts for confirmation (unless –force is used)
  6. Archives the changeset with a special marker indicating manual deletion
  7. Deletes the changeset from active changesets
  8. Outputs success message with details of what was removed

Uses:

  • ChangesetManager from pkg tools for changeset operations
  • prompt_confirm from interactive module for user confirmation
  • Styled output sections for human-readable display
  • JSON serialization for machine-readable output

The archiving step creates a backup in the workspace history directory with a special ReleaseInfo indicating this was a manual deletion, not a release. This allows recovery of accidentally deleted changesets if needed.

§Why

Safe changeset deletion is essential for:

  • Removing obsolete or incorrect changesets
  • Cleaning up after mistakes or experimental work
  • Maintaining a clean changeset directory
  • Preventing accidental data loss through confirmation prompts
  • Preserving deleted changesets for audit/recovery purposes

§Examples

use sublime_cli_tools::commands::changeset::execute_remove;
use sublime_cli_tools::cli::commands::ChangesetDeleteArgs;
use sublime_cli_tools::output::{Output, OutputFormat};
use std::io;

let args = ChangesetDeleteArgs {
    branch: "feature/old-feature".to_string(),
    force: false,
};

let output = Output::new(OutputFormat::Human, io::stdout(), false);
execute_remove(&args, &output, None, None).await?;

Functions§

execute_remove
Execute the changeset remove command.