Brijesh's Git Server — gitcc @ 6e9c8b27caead7a7c0ed64f134ef90979e06be3b

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(options: &[&str]) -> Option<usize> {
    let selection = Select::with_theme(&ColorfulTheme::default())
        .with_prompt("Select an option:")
        .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(options: &Vec<String>) -> Option<usize> {
    let selection = Select::with_theme(&ColorfulTheme::default())
        .with_prompt("Select an option:")
        .default(0)
        .items(&options)
        .interact_opt()
        .unwrap();

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

    return selection;
}