Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
term: provide default HELP message
Fintan Halpenny committed 9 months ago
commit 2a47bc0c7dd6238ce3416e19d2ba57f3a7626f64
parent a998ce691d6962ea75d861b25532f4c042c36f1a
2 files changed +11 -8
modified 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:?}")
                }
modified 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.