select_environments

Function select_environments 

Source
pub fn select_environments(
    prompt: &str,
    items: &[String],
    defaults: &[String],
    no_color: bool,
) -> Result<Vec<String>>
Expand description

Performs a multi-selection with fuzzy filtering by environment names.

Similar to select_packages but specialized for environments.

§Arguments

  • prompt - The prompt message to display
  • items - The list of environment names to choose from
  • defaults - Environment names to pre-select
  • no_color - Whether to disable colored output

§Returns

  • Result<Vec<String>> - The selected environment names

§Errors

Returns CliError::User if:

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

Returns CliError::Validation if:

  • No items are selected

§Examples

use sublime_cli_tools::interactive::select::select_environments;

let envs = vec!["dev".to_string(), "staging".to_string(), "prod".to_string()];
let defaults = vec!["staging".to_string(), "prod".to_string()];
let selected = select_environments("Select environments", &envs, &defaults, false)?;