cli: add emoji picker to `rad issue react`
The help shows that `--emoji` is optional, however it was not. Instead of making `--emoji` mandatory, I added an emoji picker for the emojis featured in the web ui. `--emoji` is now (really) optional, but can be used to react with other emojis not included in the selector or the web ui.
This commit is contained in:
parent
2af090ea1e
commit
c05434ebd5
|
|
@ -137,7 +137,7 @@ pub enum Operation {
|
||||||
},
|
},
|
||||||
React {
|
React {
|
||||||
id: Rev,
|
id: Rev,
|
||||||
reaction: Reaction,
|
reaction: Option<Reaction>,
|
||||||
comment_id: Option<thread::CommentId>,
|
comment_id: Option<thread::CommentId>,
|
||||||
},
|
},
|
||||||
Assign {
|
Assign {
|
||||||
|
|
@ -435,7 +435,7 @@ impl Args for Options {
|
||||||
},
|
},
|
||||||
OperationName::React => Operation::React {
|
OperationName::React => Operation::React {
|
||||||
id: id.ok_or_else(|| anyhow!("an issue must be provided"))?,
|
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,
|
comment_id,
|
||||||
},
|
},
|
||||||
OperationName::Delete => Operation::Delete {
|
OperationName::Delete => Operation::Delete {
|
||||||
|
|
@ -595,6 +595,11 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
Some(cid) => cid,
|
Some(cid) => cid,
|
||||||
None => *term::io::comment_select(&issue).map(|(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)?;
|
issue.react(comment_id, reaction, true, &signer)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use radicle::cob::issue::Issue;
|
use radicle::cob::issue::Issue;
|
||||||
use radicle::cob::thread::{Comment, CommentId};
|
use radicle::cob::thread::{Comment, CommentId};
|
||||||
|
use radicle::cob::Reaction;
|
||||||
use radicle::crypto::ssh::keystore::MemorySigner;
|
use radicle::crypto::ssh::keystore::MemorySigner;
|
||||||
use radicle::crypto::{ssh::Keystore, Signer};
|
use radicle::crypto::{ssh::Keystore, Signer};
|
||||||
use radicle::profile::env::RAD_PASSPHRASE;
|
use radicle::profile::env::RAD_PASSPHRASE;
|
||||||
|
|
@ -79,3 +80,13 @@ pub fn comment_select(issue: &Issue) -> anyhow::Result<(&CommentId, &Comment)> {
|
||||||
.copied()
|
.copied()
|
||||||
.ok_or(anyhow!("failed to perform comment selection"))
|
.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)?)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue