diff --git a/src/cmd.rs b/src/cmd.rs index ab17459..eede39f 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -1,3 +1,2 @@ pub mod create; -pub mod list; pub mod search; diff --git a/src/cmd/list.rs b/src/cmd/list.rs deleted file mode 100644 index 2b8ea19..0000000 --- a/src/cmd/list.rs +++ /dev/null @@ -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> { - 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(()) -} diff --git a/src/cmd/search.rs b/src/cmd/search.rs index 1a4bef1..eee42ab 100644 --- a/src/cmd/search.rs +++ b/src/cmd/search.rs @@ -1,13 +1,13 @@ use crate::jira_config::JiraConfig; use crate::types::issue::{display_issues_json, display_issues_pretty}; -pub async fn exec(json: bool, jql: String) -> Result<(), Box> { +pub async fn exec(json: bool, jql: &str) -> Result<(), Box> { let config = JiraConfig::load().map_err(|e| format!("Configuration error: {}", e))?; if !json { println!("Searching for issues..."); } - match crate::jql::run(&config, &jql).await { + match crate::jql::run(&config, jql).await { Ok(response) => { if json { if response.issues.is_empty() { diff --git a/src/main.rs b/src/main.rs index bedd888..4d70d9b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,8 +18,11 @@ async fn main() -> Result<(), Box> { open, markdown_file, } => cmd::create::create(project, open, markdown_file).await?, - Commands::List { json } => cmd::list::list(json).await?, - Commands::Search { json, jql } => cmd::search::exec(json, jql).await?, + Commands::List { json } => { + 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 } => { JiraConfig::init(url, email, token).await?; println!("Configuration initialized successfully!");