Call everything an issue rather than ticket consistently
This commit is contained in:
parent
21203eed43
commit
476fa90200
2 changed files with 29 additions and 29 deletions
|
@ -10,7 +10,7 @@ use std::path::PathBuf;
|
|||
use tempfile::NamedTempFile;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
struct TicketMetadata {
|
||||
struct IssueMetadata {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
status: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
@ -101,15 +101,15 @@ struct Status {
|
|||
name: String,
|
||||
}
|
||||
|
||||
fn get_ticket_template(
|
||||
ticket_metadata: &TicketMetadata,
|
||||
fn get_issue_template(
|
||||
issue_metadata: &IssueMetadata,
|
||||
) -> Result<String, Box<dyn std::error::Error>> {
|
||||
let matter = toml::to_string(ticket_metadata)?;
|
||||
let has_project = ticket_metadata.project.is_some();
|
||||
let matter = toml::to_string(issue_metadata)?;
|
||||
let has_project = issue_metadata.project.is_some();
|
||||
|
||||
let template = format!(
|
||||
r#"---
|
||||
# The ticket can contain the following properties:
|
||||
# The issue can contain the following properties:
|
||||
# - status
|
||||
# - project (required)
|
||||
# - assignee
|
||||
|
@ -139,9 +139,9 @@ fn get_editor() -> String {
|
|||
|
||||
fn parse_markdown(
|
||||
content: &str,
|
||||
) -> Result<(String, String, TicketMetadata), Box<dyn std::error::Error>> {
|
||||
) -> Result<(String, String, IssueMetadata), Box<dyn std::error::Error>> {
|
||||
let matter = Matter::<TOML>::new();
|
||||
let result = matter.parse_with_struct::<TicketMetadata>(content);
|
||||
let result = matter.parse_with_struct::<IssueMetadata>(content);
|
||||
|
||||
let (metadata, content) = match result {
|
||||
Some(x) => (x.data, x.content),
|
||||
|
@ -153,7 +153,7 @@ fn parse_markdown(
|
|||
|
||||
// let metadata = result.data
|
||||
// .and_then(|d| toml::from_str(d).ok())
|
||||
// .unwrap_or_else(|| TicketMetadata {
|
||||
// .unwrap_or_else(|| IssueMetadata {
|
||||
// status: None,
|
||||
// project: None,
|
||||
// assignee: None,
|
||||
|
@ -182,7 +182,7 @@ fn parse_markdown(
|
|||
fn create_temp_markdown(project_key: Option<String>) -> Result<String, Box<dyn std::error::Error>> {
|
||||
let mut temp_file = NamedTempFile::new()?;
|
||||
|
||||
let metadata = TicketMetadata {
|
||||
let metadata = IssueMetadata {
|
||||
status: None,
|
||||
project: project_key,
|
||||
assignee: None,
|
||||
|
@ -190,7 +190,7 @@ fn create_temp_markdown(project_key: Option<String>) -> Result<String, Box<dyn s
|
|||
extra: Default::default(),
|
||||
};
|
||||
|
||||
let template = get_ticket_template(&metadata)?;
|
||||
let template = get_issue_template(&metadata)?;
|
||||
|
||||
temp_file.write_all(template.as_bytes())?;
|
||||
temp_file.flush()?;
|
||||
|
@ -215,7 +215,7 @@ async fn create_jira_issue(
|
|||
project_key: &str,
|
||||
title: &str,
|
||||
description: &str,
|
||||
metadata: &TicketMetadata,
|
||||
metadata: &IssueMetadata,
|
||||
) -> Result<JiraResponse, Box<dyn std::error::Error>> {
|
||||
let client = reqwest::Client::new();
|
||||
|
||||
|
@ -356,7 +356,7 @@ pub async fn create(
|
|||
};
|
||||
|
||||
if content.trim().is_empty() {
|
||||
return Err("Empty content. Aborting ticket creation.".into());
|
||||
return Err("Empty content. Aborting issue creation.".into());
|
||||
}
|
||||
|
||||
let (title, description, metadata) = parse_markdown(&content)?;
|
||||
|
@ -375,7 +375,7 @@ pub async fn create(
|
|||
}
|
||||
|
||||
// Confirm creation
|
||||
println!("\nAbout to create ticket:");
|
||||
println!("\nAbout to create an issue:");
|
||||
println!("Project: {}", selected_project);
|
||||
if let Some(status) = &metadata.status {
|
||||
println!("Status: {}", status);
|
||||
|
@ -399,7 +399,7 @@ pub async fn create(
|
|||
|
||||
let url = format!("{}/browse/{}", config.url, response.key);
|
||||
|
||||
println!("Successfully created ticket: {}", response.key);
|
||||
println!("Successfully created issue: {}", response.key);
|
||||
println!("URL: {}", url);
|
||||
|
||||
if open {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue