git_revise/revise/prompts/
commit_ai.rs

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
use inquire::Select;

use super::Inquire;
use crate::error::ReviseResult;

#[derive(Debug, Clone)]
pub struct Part {
    pub msg: String,
    pub ans: Option<String>,
    pub options: Vec<String>,
}

impl Part {
    pub fn new(options: Vec<String>) -> Self {
        Self {
            msg: "Select the message to be committing :".to_string(),
            ans: None,
            options,
        }
    }
}

impl Inquire for Part {
    fn inquire(&mut self) -> ReviseResult<()> {
        let ans = Select::new(&self.msg, self.options.clone()).prompt()?;
        self.ans = Some(ans);
        Ok(())
    }
}