confirm_with_items

Function confirm_with_items 

Source
pub fn confirm_with_items<T: Display>(
    action: &str,
    items: &[T],
    default: bool,
    no_color: bool,
) -> Result<bool>
Expand description

Prompts user to confirm an operation that will affect multiple items.

Displays a summary of what will be affected and asks for confirmation.

§Arguments

  • action - The action to perform (e.g., “upgrade”, “delete”)
  • items - The items that will be affected
  • default - The default value if user just presses enter
  • no_color - Whether to disable colored output

§Returns

  • Result<bool> - True if user confirmed, false otherwise

§Errors

Returns CliError::User if:

  • User cancels the prompt (Ctrl+C)
  • Terminal interaction fails

§Examples

use sublime_cli_tools::interactive::confirm::confirm_with_items;

let packages = vec!["package-a", "package-b", "package-c"];
let confirmed = confirm_with_items("upgrade", &packages, true, false)?;

if confirmed {
    println!("Upgrading packages...");
}