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:
- Loads workspace configuration and validates initialization
- Creates ChangesetManager to access changeset storage
- Verifies the changeset exists
- Loads the changeset to display what will be deleted
- Prompts for confirmation (unless –force is used)
- Archives the changeset with a special marker indicating manual deletion
- Deletes the changeset from active changesets
- Outputs success message with details of what was removed
Uses:
ChangesetManagerfrom pkg tools for changeset operationsprompt_confirmfrom 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.