Skip to content

Commit

Permalink
Add no-ticket support
Browse files Browse the repository at this point in the history
  • Loading branch information
keirlawson committed Jan 23, 2024
1 parent fdd469f commit 384f70d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;
use ji::Credentials;
use std::env;
use ji::{Credentials, Issue};
use std::{collections::HashMap, env};
use structopt::StructOpt;
use url::Url;

Expand All @@ -10,6 +10,9 @@ struct Opt {
default_value = "assignee IN (currentUser()) AND sprint IN openSprints() ORDER BY created DESC"
)]
query: String,
/// If specified adds a "no ticket" option which produces the specified shortcode
#[structopt(short, long)]
no_ticket: Option<String>,
}

fn read_config() -> Result<ji::Config> {
Expand All @@ -34,7 +37,16 @@ fn main() -> Result<()> {

let config = read_config()?;

let issues = ji::search_issues(config, &opt.query)?;
let mut issues = ji::search_issues(config, &opt.query)?;

if let Some(no_ticket) = opt.no_ticket {
let mut fields = HashMap::new();
fields.insert("summary".to_owned(), "No ticket".to_owned());
issues.push(Issue {
key: no_ticket,
fields,
})
};

let issue = ji::select_issue(&issues)?;

Expand Down

0 comments on commit 384f70d

Please sign in to comment.