Compare commits
No commits in common. "86fe96f0cde83ee98fb5ecaad492cfe319ff2925" and "f0aaf0a7e79a2d4ac51d84e19be55de1fca13777" have entirely different histories.
86fe96f0cd
...
f0aaf0a7e7
4 changed files with 17 additions and 160 deletions
105
Cargo.lock
generated
105
Cargo.lock
generated
|
@ -29,21 +29,6 @@ dependencies = [
|
||||||
"zerocopy",
|
"zerocopy",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "android-tzdata"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "android_system_properties"
|
|
||||||
version = "0.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstream"
|
name = "anstream"
|
||||||
version = "0.6.18"
|
version = "0.6.18"
|
||||||
|
@ -195,21 +180,6 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "chrono"
|
|
||||||
version = "0.4.39"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825"
|
|
||||||
dependencies = [
|
|
||||||
"android-tzdata",
|
|
||||||
"iana-time-zone",
|
|
||||||
"js-sys",
|
|
||||||
"num-traits",
|
|
||||||
"serde",
|
|
||||||
"wasm-bindgen",
|
|
||||||
"windows-targets",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.27"
|
version = "4.5.27"
|
||||||
|
@ -256,16 +226,6 @@ version = "1.0.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "colored"
|
|
||||||
version = "2.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
|
|
||||||
dependencies = [
|
|
||||||
"lazy_static",
|
|
||||||
"windows-sys 0.59.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "config"
|
name = "config"
|
||||||
version = "0.15.6"
|
version = "0.15.6"
|
||||||
|
@ -705,29 +665,6 @@ dependencies = [
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "iana-time-zone"
|
|
||||||
version = "0.1.61"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220"
|
|
||||||
dependencies = [
|
|
||||||
"android_system_properties",
|
|
||||||
"core-foundation-sys",
|
|
||||||
"iana-time-zone-haiku",
|
|
||||||
"js-sys",
|
|
||||||
"wasm-bindgen",
|
|
||||||
"windows-core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "iana-time-zone-haiku"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icu_collections"
|
name = "icu_collections"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
|
@ -918,9 +855,7 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
|
||||||
name = "jirac"
|
name = "jirac"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
|
||||||
"clap",
|
"clap",
|
||||||
"colored",
|
|
||||||
"config",
|
"config",
|
||||||
"directories",
|
"directories",
|
||||||
"gray_matter",
|
"gray_matter",
|
||||||
|
@ -928,7 +863,6 @@ dependencies = [
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tabwriter",
|
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tokio",
|
"tokio",
|
||||||
"toml 0.8.19",
|
"toml 0.8.19",
|
||||||
|
@ -955,12 +889,6 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lazy_static"
|
|
||||||
version = "1.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.169"
|
version = "0.2.169"
|
||||||
|
@ -1054,15 +982,6 @@ dependencies = [
|
||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-traits"
|
|
||||||
version = "0.2.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "object"
|
name = "object"
|
||||||
version = "0.36.7"
|
version = "0.36.7"
|
||||||
|
@ -1655,15 +1574,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tabwriter"
|
|
||||||
version = "1.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fce91f2f0ec87dff7e6bcbbeb267439aa1188703003c6055193c821487400432"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-width",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempfile"
|
name = "tempfile"
|
||||||
version = "3.15.0"
|
version = "3.15.0"
|
||||||
|
@ -1904,12 +1814,6 @@ version = "1.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
|
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-width"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "untrusted"
|
name = "untrusted"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
|
@ -2053,15 +1957,6 @@ dependencies = [
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-core"
|
|
||||||
version = "0.52.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
|
|
||||||
dependencies = [
|
|
||||||
"windows-targets",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-registry"
|
name = "windows-registry"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|
|
@ -9,12 +9,10 @@ reqwest = { version = "0.12", features = ["json"] }
|
||||||
tokio = { version = "1.0", features = ["full"] }
|
tokio = { version = "1.0", features = ["full"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
colored = "2.0"
|
#colored = "2.0"
|
||||||
toml = "0.8"
|
toml = "0.8"
|
||||||
config = "0.15"
|
config = "0.15"
|
||||||
directories = "6.0"
|
directories = "6.0"
|
||||||
tempfile = "3.8"
|
tempfile = "3.8"
|
||||||
gray_matter = { version = "0.2", default-features = false, features = ["toml"] }
|
gray_matter = { version = "0.2", default-features = false, features = ["toml"] }
|
||||||
open = "5.2"
|
open = "5.2"
|
||||||
chrono = { version = "0.4", features = ["serde"] }
|
|
||||||
tabwriter = "1.4"
|
|
|
@ -1,28 +1,18 @@
|
||||||
use crate::jira_config::JiraConfig;
|
use crate::jira_config::JiraConfig;
|
||||||
use colored::Colorize;
|
|
||||||
use reqwest::header::{HeaderMap, HeaderValue, CONTENT_TYPE};
|
use reqwest::header::{HeaderMap, HeaderValue, CONTENT_TYPE};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
struct JiraIssue {
|
struct JiraIssue {
|
||||||
key: String,
|
key: String,
|
||||||
#[serde(rename = "self")]
|
|
||||||
href: String,
|
|
||||||
fields: JiraIssueResponseFields,
|
fields: JiraIssueResponseFields,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
struct JiraIssueResponseFields {
|
struct JiraIssueResponseFields {
|
||||||
summary: String,
|
summary: String,
|
||||||
status: Status,
|
status: Status,
|
||||||
created: chrono::DateTime<chrono::Utc>,
|
created: String,
|
||||||
priority: Priority,
|
|
||||||
assignee: Person,
|
|
||||||
reporter: Person,
|
|
||||||
creator: Person,
|
|
||||||
#[serde(rename = "duedate")]
|
|
||||||
due_date: Option<chrono::NaiveDate>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
@ -31,29 +21,11 @@ struct JiraSearchResponse {
|
||||||
total: u32,
|
total: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
struct Status {
|
struct Status {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
|
||||||
struct Priority {
|
|
||||||
name: String,
|
|
||||||
id: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
|
||||||
struct Person {
|
|
||||||
#[serde(rename = "self")]
|
|
||||||
href: String,
|
|
||||||
#[serde(rename = "displayName")]
|
|
||||||
display_name: String,
|
|
||||||
#[serde(rename = "accountId")]
|
|
||||||
account_id: String,
|
|
||||||
#[serde(rename = "emailAddress")]
|
|
||||||
email_address: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn list_jira_issues(
|
async fn list_jira_issues(
|
||||||
config: &JiraConfig,
|
config: &JiraConfig,
|
||||||
) -> Result<JiraSearchResponse, Box<dyn std::error::Error>> {
|
) -> Result<JiraSearchResponse, Box<dyn std::error::Error>> {
|
||||||
|
@ -83,26 +55,18 @@ async fn list_jira_issues(
|
||||||
Ok(response.json::<JiraSearchResponse>().await?)
|
Ok(response.json::<JiraSearchResponse>().await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_issues_pretty(issues: &[JiraIssue]) -> Result<(), Box<dyn std::error::Error>> {
|
fn display_issues_pretty(issues: &[JiraIssue], jira_url: &str) {
|
||||||
println!("Found {} issues:", issues.len());
|
println!("Found {} issues:", issues.len());
|
||||||
println!("{:-<80}", "");
|
println!("{:-<80}", "");
|
||||||
|
|
||||||
for issue in issues {
|
for issue in issues {
|
||||||
let mut tw = tabwriter::TabWriter::new(vec![]);
|
println!("Key: {}", issue.key);
|
||||||
writeln!(tw, "{}:\t{}", "Key".blue(), issue.key)?;
|
println!("Summary: {}", issue.fields.summary);
|
||||||
writeln!(tw, "{}:\t{}", "Summary".blue(), issue.fields.summary)?;
|
println!("Status: {}", issue.fields.status.name);
|
||||||
writeln!(tw, "{}:\t{}", "Status".blue(), issue.fields.status.name)?;
|
println!("Created: {}", issue.fields.created);
|
||||||
writeln!(tw, "{}:\t{}", "Created".blue(), issue.fields.created)?;
|
println!("URL: {}/browse/{}", jira_url, issue.key);
|
||||||
writeln!(tw, "{}:\t{:?}", "Due Date".blue(), issue.fields.due_date)?;
|
|
||||||
writeln!(tw, "{}:\t{}", "URL".blue(), issue.href.underline())?;
|
|
||||||
tw.flush().unwrap();
|
|
||||||
|
|
||||||
let written = String::from_utf8(tw.into_inner().unwrap()).unwrap();
|
|
||||||
print!("{}", written);
|
|
||||||
println!("{:-<80}", "");
|
println!("{:-<80}", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_issues_json(issues: &[JiraIssue]) -> Result<(), Box<dyn std::error::Error>> {
|
fn display_issues_json(issues: &[JiraIssue]) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
@ -128,7 +92,7 @@ pub async fn list(json: bool) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
} else if response.issues.is_empty() {
|
} else if response.issues.is_empty() {
|
||||||
println!("No open issues found for assigned to you");
|
println!("No open issues found for assigned to you");
|
||||||
} else {
|
} else {
|
||||||
display_issues_pretty(&response.issues)?;
|
display_issues_pretty(&response.issues, &config.url);
|
||||||
println!("Total issues: {}", response.total);
|
println!("Total issues: {}", response.total);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue