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 list;
|
||||
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::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))?;
|
||||
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() {
|
||||
|
|
|
@ -18,8 +18,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
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!");
|
||||
|
|
Loading…
Reference in a new issue