Compare commits
No commits in common. "7af1f40188c3eb74cbb58f37929124274aff4822" and "f05461f1f7a615026d084aa193ca54a65aaef558" have entirely different histories.
7af1f40188
...
f05461f1f7
6 changed files with 9 additions and 47 deletions
|
@ -12,7 +12,6 @@ pub struct Cli {
|
||||||
pub enum FormatMode {
|
pub enum FormatMode {
|
||||||
Pretty,
|
Pretty,
|
||||||
Json,
|
Json,
|
||||||
Compact,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for FormatMode {
|
impl std::fmt::Display for FormatMode {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::cli::FormatMode;
|
use crate::cli::FormatMode;
|
||||||
use crate::jira_config::JiraConfig;
|
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<dyn std::error::Error>> {
|
pub async fn exec(output: FormatMode, jql: &str) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let config = JiraConfig::load().map_err(|e| format!("Configuration error: {}", e))?;
|
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<dyn std::erro
|
||||||
}
|
}
|
||||||
(FormatMode::Json, false) => display_issues_json(&result.issues)?,
|
(FormatMode::Json, false) => display_issues_json(&result.issues)?,
|
||||||
(FormatMode::Json, true) => println!("[]"),
|
(FormatMode::Json, true) => println!("[]"),
|
||||||
(FormatMode::Compact, false) => display_issues_compact(&result.issues)?,
|
|
||||||
(FormatMode::Compact, true) => {
|
|
||||||
println!("No results found for query.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::cli::FormatMode;
|
use crate::cli::FormatMode;
|
||||||
use crate::jira_config::JiraConfig;
|
use crate::jira_config::JiraConfig;
|
||||||
use crate::term::hyperlink;
|
|
||||||
use crate::types::issue::JiraIssue;
|
use crate::types::issue::JiraIssue;
|
||||||
use crossterm::style::{Color, Stylize};
|
use crossterm::style::{Color, Stylize};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
@ -100,11 +99,9 @@ fn pretty_print(issue: &JiraIssue) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
}
|
}
|
||||||
println!("\n== Actions {:=<69}", "");
|
println!("\n== Actions {:=<69}", "");
|
||||||
println!(
|
println!(
|
||||||
"{}",
|
"\u{1b}]8;;{}\u{7}{}\u{1b}]8;;\u{7}",
|
||||||
hyperlink(
|
issue.href,
|
||||||
&issue.href,
|
"Open Issue".green().underline(Color::Green)
|
||||||
&"Open Issue".green().underline(Color::Green).to_string()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -145,7 +142,6 @@ pub async fn exec(output: FormatMode, issue_key: &str) -> Result<(), Box<dyn std
|
||||||
match output {
|
match output {
|
||||||
FormatMode::Pretty => pretty_print(&fetched_issue)?,
|
FormatMode::Pretty => pretty_print(&fetched_issue)?,
|
||||||
FormatMode::Json => json_print(&fetched_issue)?,
|
FormatMode::Json => json_print(&fetched_issue)?,
|
||||||
FormatMode::Compact => todo!(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -2,7 +2,6 @@ mod cli;
|
||||||
mod cmd;
|
mod cmd;
|
||||||
mod jira_config;
|
mod jira_config;
|
||||||
mod jql;
|
mod jql;
|
||||||
mod term;
|
|
||||||
mod types;
|
mod types;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
@ -20,8 +19,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
markdown_file,
|
markdown_file,
|
||||||
} => cmd::create::create(project, open, markdown_file).await?,
|
} => cmd::create::create(project, open, markdown_file).await?,
|
||||||
Commands::List { output } => {
|
Commands::List { output } => {
|
||||||
let jql =
|
let jql = "assignee = currentUser() AND resolution = Unresolved order by updated DESC";
|
||||||
"assignee = currentUser() AND resolution = Unresolved order by project,updated ASC";
|
|
||||||
cmd::search::exec(output, jql).await?
|
cmd::search::exec(output, jql).await?
|
||||||
}
|
}
|
||||||
Commands::Search { output, jql } => cmd::search::exec(output, &jql).await?,
|
Commands::Search { output, jql } => cmd::search::exec(output, &jql).await?,
|
||||||
|
|
|
@ -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)
|
|
||||||
}
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::term::hyperlink;
|
use crossterm::style::Stylize;
|
||||||
use crossterm::style::{Color, Stylize};
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
|
@ -108,8 +107,9 @@ pub fn display_issues_pretty(issues: &[JiraIssue]) -> Result<(), Box<dyn std::er
|
||||||
)?;
|
)?;
|
||||||
writeln!(
|
writeln!(
|
||||||
tw,
|
tw,
|
||||||
"{}",
|
"\u{1b}]8;;{}\u{7}{}\u{1b}]8;;\u{7}",
|
||||||
&hyperlink(&issue.href, &"Open Issue".green().to_string())
|
issue.href,
|
||||||
|
"Open Issue".green()
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
tw.flush().unwrap();
|
tw.flush().unwrap();
|
||||||
|
@ -122,30 +122,6 @@ pub fn display_issues_pretty(issues: &[JiraIssue]) -> Result<(), Box<dyn std::er
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn display_issues_compact(issues: &[JiraIssue]) -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
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<dyn std::error::Error>> {
|
pub fn display_issues_json(issues: &[JiraIssue]) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let j = serde_json::to_string_pretty(issues)?;
|
let j = serde_json::to_string_pretty(issues)?;
|
||||||
println!("{}", j);
|
println!("{}", j);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue