Compare commits

...

2 commits

View file

@ -211,13 +211,13 @@ fn create_temp_markdown(project_key: Option<String>) -> Result<String, Box<dyn s
Ok(content) Ok(content)
} }
async fn create_jira_issue( async fn create_jira_issue(
_config: &JiraConfig, config: &JiraConfig,
project_key: &str, project_key: &str,
title: &str, title: &str,
description: &str, description: &str,
metadata: &TicketMetadata, metadata: &TicketMetadata,
) -> Result<JiraResponse, Box<dyn std::error::Error>> { ) -> Result<JiraResponse, Box<dyn std::error::Error>> {
let _client = reqwest::Client::new(); let client = reqwest::Client::new();
let mut headers = HeaderMap::new(); let mut headers = HeaderMap::new();
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json")); headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
@ -257,32 +257,32 @@ async fn create_jira_issue(
let issue = JiraIssueRequest { fields, update }; let issue = JiraIssueRequest { fields, update };
println!("{:#?}", issue); // println!("{:#?}", issue);
Ok(JiraResponse { // Ok(JiraResponse {
key: format!("{}-1234", project_key), // key: format!("{}-1234", project_key),
}) // })
// let response = client let response = client
// .post(format!("{}/rest/api/2/issue", config.url)) .post(format!("{}/rest/api/2/issue", config.url))
// .basic_auth(&config.email, Some(&config.api_token)) .basic_auth(&config.email, Some(&config.api_token))
// .headers(headers) .headers(headers)
// .json(&issue) .json(&issue)
// .send() .send()
// .await?; .await?;
//
// if !response.status().is_success() { if !response.status().is_success() {
// let error_text = response.text().await?; let error_text = response.text().await?;
// return Err(format!("Failed to create issue: {}", error_text).into()); return Err(format!("Failed to create issue: {}", error_text).into());
// } }
//
// let issue_response = response.json::<JiraResponse>().await?; let issue_response = response.json::<JiraResponse>().await?;
//
// // Update status if specified (requires a separate API call) // Update status if specified (requires a separate API call)
// if let Some(status) = &metadata.status { if let Some(status) = &metadata.status {
// update_issue_status(config, &issue_response.key, status).await?; update_issue_status(config, &issue_response.key, status).await?;
// } }
//
// Ok(issue_response) Ok(issue_response)
} }
async fn update_issue_status( async fn update_issue_status(
@ -376,9 +376,19 @@ pub async fn create(
// Confirm creation // Confirm creation
println!("\nAbout to create ticket:"); println!("\nAbout to create ticket:");
println!("Project: {}", selected_project);
if let Some(status) = &metadata.status {
println!("Status: {}", status);
}
if let Some(assignee) = &metadata.assignee {
println!("Assignee: {}", assignee);
}
if let Some(parent) = &metadata.parent {
println!("Parent: {}", parent);
}
println!("Title: {}", title); println!("Title: {}", title);
println!("{}", description);
// println!("{}...", &description.chars().take(100).collect::<String>()); println!("Description:\n{}", description);
println!("\nPress Enter to continue or Ctrl+C to abort"); println!("\nPress Enter to continue or Ctrl+C to abort");
let mut input = String::new(); let mut input = String::new();