diff --git a/src/cli.rs b/src/cli.rs index ca58d29..ede5de4 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -12,7 +12,6 @@ pub struct Cli { pub enum FormatMode { Pretty, Json, - Compact, } impl std::fmt::Display for FormatMode { diff --git a/src/cmd/search.rs b/src/cmd/search.rs index e2dd050..5781443 100644 --- a/src/cmd/search.rs +++ b/src/cmd/search.rs @@ -1,6 +1,6 @@ use crate::cli::FormatMode; use crate::jira_config::JiraConfig; -use crate::types::issue::{display_issues_compact, display_issues_json, display_issues_pretty}; +use crate::types::issue::{display_issues_json, display_issues_pretty}; pub async fn exec(output: FormatMode, jql: &str) -> Result<(), Box> { let config = JiraConfig::load().map_err(|e| format!("Configuration error: {}", e))?; @@ -26,10 +26,6 @@ pub async fn exec(output: FormatMode, jql: &str) -> Result<(), Box display_issues_json(&result.issues)?, (FormatMode::Json, true) => println!("[]"), - (FormatMode::Compact, false) => display_issues_compact(&result.issues)?, - (FormatMode::Compact, true) => { - println!("No results found for query."); - } } Ok(()) diff --git a/src/cmd/view.rs b/src/cmd/view.rs index 752fe5d..72cdeda 100644 --- a/src/cmd/view.rs +++ b/src/cmd/view.rs @@ -1,6 +1,5 @@ use crate::cli::FormatMode; use crate::jira_config::JiraConfig; -use crate::term::hyperlink; use crate::types::issue::JiraIssue; use crossterm::style::{Color, Stylize}; use std::io::Write; @@ -100,11 +99,9 @@ fn pretty_print(issue: &JiraIssue) -> Result<(), Box> { } println!("\n== Actions {:=<69}", ""); println!( - "{}", - hyperlink( - &issue.href, - &"Open Issue".green().underline(Color::Green).to_string() - ) + "\u{1b}]8;;{}\u{7}{}\u{1b}]8;;\u{7}", + issue.href, + "Open Issue".green().underline(Color::Green) ); Ok(()) @@ -145,7 +142,6 @@ pub async fn exec(output: FormatMode, issue_key: &str) -> Result<(), Box pretty_print(&fetched_issue)?, FormatMode::Json => json_print(&fetched_issue)?, - FormatMode::Compact => todo!(), } Ok(()) diff --git a/src/main.rs b/src/main.rs index 199f533..33d5ec2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,6 @@ mod cli; mod cmd; mod jira_config; mod jql; -mod term; mod types; use clap::Parser; @@ -20,8 +19,7 @@ async fn main() -> Result<(), Box> { markdown_file, } => cmd::create::create(project, open, markdown_file).await?, Commands::List { output } => { - let jql = - "assignee = currentUser() AND resolution = Unresolved order by project,updated ASC"; + let jql = "assignee = currentUser() AND resolution = Unresolved order by updated DESC"; cmd::search::exec(output, jql).await? } Commands::Search { output, jql } => cmd::search::exec(output, &jql).await?, diff --git a/src/term.rs b/src/term.rs deleted file mode 100644 index 1f2203c..0000000 --- a/src/term.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub fn hyperlink(url: &str, text: &str) -> String { - format!("\u{1b}]8;;{}\u{7}{}\u{1b}]8;;\u{7}", url, text) -} diff --git a/src/types/issue.rs b/src/types/issue.rs index ac009a8..455cb1b 100644 --- a/src/types/issue.rs +++ b/src/types/issue.rs @@ -1,5 +1,4 @@ -use crate::term::hyperlink; -use crossterm::style::{Color, Stylize}; +use crossterm::style::Stylize; use serde::{Deserialize, Serialize}; use std::io::Write; @@ -108,8 +107,9 @@ pub fn display_issues_pretty(issues: &[JiraIssue]) -> Result<(), Box Result<(), Box Result<(), Box> { - println!("Found {} issues:", issues.len()); - println!("{:-<80}", ""); - - let mut tw = tabwriter::TabWriter::new(vec![]); - for issue in issues { - writeln!( - tw, - "{}:\t{}", - hyperlink( - &issue.href, - &issue.key.clone().blue().underline(Color::Blue).to_string() - ), - issue.fields.summary.clone().green() - )?; - } - - tw.flush().unwrap(); - let written = String::from_utf8(tw.into_inner().unwrap()).unwrap(); - print!("{}", written); - - Ok(()) -} - pub fn display_issues_json(issues: &[JiraIssue]) -> Result<(), Box> { let j = serde_json::to_string_pretty(issues)?; println!("{}", j);