Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Parse tags and assignees on new issue form
Erik Kundt committed 2 years ago
commit ad493fce604004b610c8c6cd0070919b1765f264
parent 2dfc0a9e4d42bd21ebaa1bedeaf0bca69b3900fb
2 files changed +25 -6
modified src/app.rs
@@ -325,8 +325,8 @@ impl App {
        let repository = self.context.repository();
        let signer = self.context.signer();

-
        let tags = cob::parse_tags(tags);
-
        let assignees = cob::parse_assigness(assignees);
+
        let tags = cob::parse_tags(tags)?;
+
        let assignees = cob::parse_assignees(assignees)?;

        cob::issue::create(
            repository,
modified src/cob.rs
@@ -1,12 +1,31 @@
+
use std::str::FromStr;
+

+
use anyhow::Result;
use radicle::cob::{ActorId, Tag};

pub mod issue;
pub mod patch;

-
pub fn parse_tags(tags: String) -> Vec<Tag> {
-
    vec![]
+
pub fn parse_tags(input: String) -> Result<Vec<Tag>> {
+
    let mut tags = vec![];
+
    for name in input.split(',') {
+
        match Tag::new(name.trim()) {
+
            Ok(tag) => tags.push(tag),
+
            Err(err) => return Err(anyhow::anyhow!(err).context("Can't parse tags.")),
+
        }
+
    }
+

+
    Ok(tags)
}

-
pub fn parse_assigness(assignees: String) -> Vec<ActorId> {
-
    vec![]
+
pub fn parse_assignees(input: String) -> Result<Vec<ActorId>> {
+
    let mut assignees = vec![];
+
    for did in input.split(',') {
+
        match ActorId::from_str(did) {
+
            Ok(actor) => assignees.push(actor),
+
            Err(err) => return Err(anyhow::anyhow!(err).context("Can't parse assignees.")),
+
        }
+
    }
+

+
    Ok(assignees)
}