git_revise/revise/prompts/
commit_edit.rs

1use inquire::{
2    ui::{Color, RenderConfig, Styled},
3    Editor,
4};
5
6use super::Inquire;
7use crate::error::ReviseResult;
8
9#[derive(Debug, Clone)]
10pub struct Part {
11    pub msg: String,
12    pub ans: Option<String>,
13    pub commit: String,
14    pub fg: Color,
15}
16
17impl Part {
18    pub fn new(commit: String) -> Self {
19        Self {
20            msg: "You really want to edit this commit manually?".to_string(),
21            ans: None,
22            commit,
23            fg: Color::LightRed,
24        }
25    }
26}
27
28impl Inquire for Part {
29    fn inquire(&mut self) -> ReviseResult<()> {
30        let ans = Editor::new("")
31            .with_predefined_text(&self.commit)
32            .with_render_config(RenderConfig::default().with_prompt_prefix(
33                Styled::new(self.msg.as_str()).with_fg(self.fg),
34            ))
35            .prompt()?;
36        self.ans = Some(ans);
37        Ok(())
38    }
39}