simple_select

Function simple_select 

Source
pub fn simple_select<T: ToString>(
    prompt: &str,
    items: &[T],
    default: Option<usize>,
    no_color: bool,
) -> Result<usize>
Expand description

Performs a single selection without fuzzy search.

This is a simpler version for cases where fuzzy search is not needed.

§Arguments

  • prompt - The prompt message to display
  • items - The list of items to choose from
  • default - Optional default selection index
  • no_color - Whether to disable colored output

§Returns

  • Result<usize> - The index of the selected item

§Errors

Returns CliError::User if:

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

§Examples

use sublime_cli_tools::interactive::select::simple_select;

let options = vec!["patch", "minor", "major"];
let selection = simple_select("Select bump type", &options, Some(0), false)?;