Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: add emoji picker to `rad issue react`
tippfehlr committed 1 year ago
commit c05434ebd5a2335f432db9ac1820f3e4ba181e68
parent 2af090ea1eb6ac806d9598f657c60c5327c12143
2 files changed +18 -2
modified radicle-cli/src/commands/issue.rs
@@ -137,7 +137,7 @@ pub enum Operation {
    },
    React {
        id: Rev,
-
        reaction: Reaction,
+
        reaction: Option<Reaction>,
        comment_id: Option<thread::CommentId>,
    },
    Assign {
@@ -435,7 +435,7 @@ impl Args for Options {
            },
            OperationName::React => Operation::React {
                id: id.ok_or_else(|| anyhow!("an issue must be provided"))?,
-
                reaction: reaction.ok_or_else(|| anyhow!("a reaction emoji must be provided"))?,
+
                reaction,
                comment_id,
            },
            OperationName::Delete => Operation::Delete {
@@ -595,6 +595,11 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
                    Some(cid) => cid,
                    None => *term::io::comment_select(&issue).map(|(cid, _)| cid)?,
                };
+
                let reaction = match reaction {
+
                    Some(reaction) => reaction,
+
                    None => term::io::reaction_select()?,
+
                };
+
                // SAFETY: reaction is never None here.
                issue.react(comment_id, reaction, true, &signer)?;
            }
        }
modified radicle-cli/src/terminal/io.rs
@@ -1,6 +1,7 @@
use anyhow::anyhow;
use radicle::cob::issue::Issue;
use radicle::cob::thread::{Comment, CommentId};
+
use radicle::cob::Reaction;
use radicle::crypto::ssh::keystore::MemorySigner;
use radicle::crypto::{ssh::Keystore, Signer};
use radicle::profile::env::RAD_PASSPHRASE;
@@ -79,3 +80,13 @@ pub fn comment_select(issue: &Issue) -> anyhow::Result<(&CommentId, &Comment)> {
        .copied()
        .ok_or(anyhow!("failed to perform comment selection"))
}
+

+
pub fn reaction_select() -> anyhow::Result<Reaction> {
+
    let emoji = Select::new(
+
        "With which emoji do you want to react?",
+
        vec!['🐙', '👾', '💯', '✨', '🙇', '🙅', '❤'],
+
    )
+
    .with_render_config(*CONFIG)
+
    .prompt()?;
+
    Ok(Reaction::new(emoji)?)
+
}