radicle-cli: Correct operation name

Change `OperationName::Create` to `OperationName::Open` and change the
command argument to reflect this.

Signed-off-by: Slack Coder <slackcoder@server.ky>
This commit is contained in:
Slack Coder 2023-01-10 10:37:40 -05:00 committed by Alexis Sellier
parent eedf08031d
commit 897d439f95
No known key found for this signature in database
2 changed files with 14 additions and 14 deletions

View File

@ -4,7 +4,7 @@ using the 'issue' subcommand.
Let's say the new car you are designing with your peers has a problem with its flux capacitor. Let's say the new car you are designing with your peers has a problem with its flux capacitor.
``` ```
$ rad issue new --title "flux capacitor underpowered" --description "Flux capacitor power requirements exceed current supply" $ rad issue open --title "flux capacitor underpowered" --description "Flux capacitor power requirements exceed current supply"
``` ```
The issue is now listed under our project. The issue is now listed under our project.

View File

@ -21,12 +21,12 @@ pub const HELP: Help = Help {
Usage Usage
rad issue rad issue
rad issue new [--title <title>] [--description <text>] rad issue delete <id>
rad issue list [--assigned <key>]
rad issue open [--title <title>] [--description <text>]
rad issue react <id> [--emoji <char>]
rad issue show <id> rad issue show <id>
rad issue state <id> [--closed | --open | --solved] rad issue state <id> [--closed | --open | --solved]
rad issue delete <id>
rad issue react <id> [--emoji <char>]
rad issue list [--assigned <key>]
Options Options
@ -42,7 +42,7 @@ pub struct Metadata {
#[derive(Default, Debug, PartialEq, Eq)] #[derive(Default, Debug, PartialEq, Eq)]
pub enum OperationName { pub enum OperationName {
Create, Open,
Delete, Delete,
#[default] #[default]
List, List,
@ -61,7 +61,7 @@ pub enum Assigned {
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub enum Operation { pub enum Operation {
Create { Open {
title: Option<String>, title: Option<String>,
description: Option<String>, description: Option<String>,
}, },
@ -107,7 +107,7 @@ impl Args for Options {
Long("help") => { Long("help") => {
return Err(Error::Help.into()); return Err(Error::Help.into());
} }
Long("title") if op == Some(OperationName::Create) => { Long("title") if op == Some(OperationName::Open) => {
title = Some(parser.value()?.to_string_lossy().into()); title = Some(parser.value()?.to_string_lossy().into());
} }
Long("closed") if op == Some(OperationName::State) => { Long("closed") if op == Some(OperationName::State) => {
@ -129,7 +129,7 @@ impl Args for Options {
Some(Reaction::from_str(emoji).map_err(|_| anyhow!("invalid emoji"))?); Some(Reaction::from_str(emoji).map_err(|_| anyhow!("invalid emoji"))?);
} }
} }
Long("description") if op == Some(OperationName::Create) => { Long("description") if op == Some(OperationName::Open) => {
description = Some(parser.value()?.to_string_lossy().into()); description = Some(parser.value()?.to_string_lossy().into());
} }
Long("assigned") | Short('a') if assigned.is_none() => { Long("assigned") | Short('a') if assigned.is_none() => {
@ -144,12 +144,12 @@ impl Args for Options {
} }
} }
Value(val) if op.is_none() => match val.to_string_lossy().as_ref() { Value(val) if op.is_none() => match val.to_string_lossy().as_ref() {
"n" | "new" => op = Some(OperationName::Create),
"c" | "show" => op = Some(OperationName::Show), "c" | "show" => op = Some(OperationName::Show),
"s" | "state" => op = Some(OperationName::State),
"d" | "delete" => op = Some(OperationName::Delete), "d" | "delete" => op = Some(OperationName::Delete),
"l" | "list" => op = Some(OperationName::List), "l" | "list" => op = Some(OperationName::List),
"o" | "open" => op = Some(OperationName::Open),
"r" | "react" => op = Some(OperationName::React), "r" | "react" => op = Some(OperationName::React),
"s" | "state" => op = Some(OperationName::State),
unknown => anyhow::bail!("unknown operation '{}'", unknown), unknown => anyhow::bail!("unknown operation '{}'", unknown),
}, },
@ -170,7 +170,7 @@ impl Args for Options {
} }
let op = match op.unwrap_or_default() { let op = match op.unwrap_or_default() {
OperationName::Create => Operation::Create { title, description }, OperationName::Open => Operation::Open { title, description },
OperationName::Show => Operation::Show { OperationName::Show => Operation::Show {
id: id.ok_or_else(|| anyhow!("an issue id must be provided"))?, id: id.ok_or_else(|| anyhow!("an issue id must be provided"))?,
}, },
@ -201,7 +201,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
let mut issues = Issues::open(*signer.public_key(), &repo)?; let mut issues = Issues::open(*signer.public_key(), &repo)?;
match options.op { match options.op {
Operation::Create { Operation::Open {
title: Some(title), title: Some(title),
description: Some(description), description: Some(description),
} => { } => {
@ -223,7 +223,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
issue.react(comment_id, reaction, &signer)?; issue.react(comment_id, reaction, &signer)?;
} }
} }
Operation::Create { title, description } => { Operation::Open { title, description } => {
let meta = Metadata { let meta = Metadata {
title: title.unwrap_or("Enter a title".to_owned()), title: title.unwrap_or("Enter a title".to_owned()),
labels: vec![], labels: vec![],