Brijesh's Git Server — gitcc @ e842b23b5d9b80521bf8425c845deb83efb13d9f

failed attempt at automatic git workflow

src/utils.rs (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
use dialoguer::{theme::ColorfulTheme, Select};

pub fn select_option(prompt: &str, options: &[&str]) -> Option<usize> {
    let selection = Select::with_theme(&ColorfulTheme::default())
        .with_prompt(prompt)
        .default(0)
        .items(options)
        .interact_opt()
        .unwrap();

    if selection.is_none() {
        println!("Please choose an option");
        std::process::exit(1);
    }

    return selection;
}

pub fn select_option_string_vec(prompt: &str, options: &Vec<String>) -> Option<usize> {
    let selection = Select::with_theme(&ColorfulTheme::default())
        .with_prompt(prompt)
        .default(0)
        .items(&options)
        .interact_opt()
        .unwrap();

    if selection.is_none() {
        println!("Please choose an option");
        std::process::exit(1);
    }

    return selection;
}