Merge the list command into search
This commit is contained in:
parent
0c459e2770
commit
5233ef19fc
4 changed files with 7 additions and 39 deletions
|
@ -1,3 +1,2 @@
|
||||||
pub mod create;
|
pub mod create;
|
||||||
pub mod list;
|
|
||||||
pub mod search;
|
pub mod search;
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
use crate::jira_config::JiraConfig;
|
|
||||||
use crate::types::issue::{display_issues_json, display_issues_pretty};
|
|
||||||
|
|
||||||
pub async fn list(json: bool) -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let config = JiraConfig::load().map_err(|e| format!("Configuration error: {}", e))?;
|
|
||||||
if !json {
|
|
||||||
println!("Fetching issues assigned...");
|
|
||||||
}
|
|
||||||
|
|
||||||
let jql = "assignee = currentUser() AND resolution = Unresolved order by updated DESC";
|
|
||||||
|
|
||||||
match crate::jql::run(&config, jql).await {
|
|
||||||
Ok(response) => {
|
|
||||||
if json {
|
|
||||||
if response.issues.is_empty() {
|
|
||||||
println!("[]");
|
|
||||||
} else {
|
|
||||||
display_issues_json(&response.issues)?;
|
|
||||||
}
|
|
||||||
} else if response.issues.is_empty() {
|
|
||||||
println!("No open issues found for assigned to you");
|
|
||||||
} else {
|
|
||||||
display_issues_pretty(&response.issues)?;
|
|
||||||
println!("Total issues: {}", response.total);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
eprintln!("Error fetching issues: {}", e);
|
|
||||||
std::process::exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
|
@ -1,13 +1,13 @@
|
||||||
use crate::jira_config::JiraConfig;
|
use crate::jira_config::JiraConfig;
|
||||||
use crate::types::issue::{display_issues_json, display_issues_pretty};
|
use crate::types::issue::{display_issues_json, display_issues_pretty};
|
||||||
|
|
||||||
pub async fn exec(json: bool, jql: String) -> Result<(), Box<dyn std::error::Error>> {
|
pub async fn exec(json: bool, 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))?;
|
||||||
if !json {
|
if !json {
|
||||||
println!("Searching for issues...");
|
println!("Searching for issues...");
|
||||||
}
|
}
|
||||||
|
|
||||||
match crate::jql::run(&config, &jql).await {
|
match crate::jql::run(&config, jql).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
if json {
|
if json {
|
||||||
if response.issues.is_empty() {
|
if response.issues.is_empty() {
|
||||||
|
|
|
@ -18,8 +18,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
open,
|
open,
|
||||||
markdown_file,
|
markdown_file,
|
||||||
} => cmd::create::create(project, open, markdown_file).await?,
|
} => cmd::create::create(project, open, markdown_file).await?,
|
||||||
Commands::List { json } => cmd::list::list(json).await?,
|
Commands::List { json } => {
|
||||||
Commands::Search { json, jql } => cmd::search::exec(json, jql).await?,
|
let jql = "assignee = currentUser() AND resolution = Unresolved order by updated DESC";
|
||||||
|
cmd::search::exec(json, jql).await?
|
||||||
|
},
|
||||||
|
Commands::Search { json, jql } => cmd::search::exec(json, &jql).await?,
|
||||||
Commands::Init { url, email, token } => {
|
Commands::Init { url, email, token } => {
|
||||||
JiraConfig::init(url, email, token).await?;
|
JiraConfig::init(url, email, token).await?;
|
||||||
println!("Configuration initialized successfully!");
|
println!("Configuration initialized successfully!");
|
||||||
|
|
Loading…
Reference in a new issue