diff --git a/crates/radicle-cli/src/commands/config.rs b/crates/radicle-cli/src/commands/config.rs index 402e5a46..33fe7033 100644 --- a/crates/radicle-cli/src/commands/config.rs +++ b/crates/radicle-cli/src/commands/config.rs @@ -188,15 +188,16 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { Operation::Edit => { let config = std::fs::read_to_string(&path)?; - match term::editor::Editor::new("Change configuration.", "You may change the Radicle configuration using your editor. Pressing (e) will open the editor. Save the file and exit the editor to submit your changes.") - .editor(term::editor::default_editor_command().as_ref()) - .extension(".json") - .initial(&config) - .edit()? { + match term::editor::Editor::new("Edit configuration", term::editor::Editor::HELP) + .editor(term::editor::default_editor_command().as_ref()) + .extension(".json") + .initial(&config) + .edit()? + { Some(edited) => { std::fs::write(&path, edited)?; term::success!("Successfully made changes to the configuration at {path:?}"); - }, + } None => { term::info!("No changes were made to the configuration at {path:?}") } diff --git a/crates/radicle-term/src/editor.rs b/crates/radicle-term/src/editor.rs index 9a1ba68c..de96e74c 100644 --- a/crates/radicle-term/src/editor.rs +++ b/crates/radicle-term/src/editor.rs @@ -12,10 +12,12 @@ pub struct Editor<'a>(pub inquire::Editor<'a>); #[error(transparent)] pub struct Error(#[from] InquireError); -impl Editor<'_> { +impl<'a> Editor<'a> { + pub const HELP: &'a str = "(e) to edit. (enter) to save and exit. (esc) to cancel and quit."; + /// Create a new editor for editing a comment. pub fn comment() -> Self { - Self::new("Enter comment.", "You may enter your comment using your editor. Pressing (e) will open the editor. Save the file and exit the editor to submit your comment.") + Self::new("Enter comment.", Self::HELP) } /// Open the editor and return the edited text.