Add an --open flag to the create command to open the new ticket in a browser
This commit is contained in:
parent
f5e31c3a73
commit
63b1f33a0a
5 changed files with 46 additions and 3 deletions
|
@ -14,6 +14,9 @@ pub enum Commands {
|
|||
#[arg(long)]
|
||||
project: Option<String>,
|
||||
|
||||
#[arg(long)]
|
||||
open: bool,
|
||||
|
||||
#[arg(value_name = "MARKDOWN_FILE")]
|
||||
markdown_file: Option<PathBuf>,
|
||||
},
|
||||
|
|
|
@ -340,6 +340,7 @@ async fn update_issue_status(
|
|||
|
||||
pub async fn create(
|
||||
project: Option<String>,
|
||||
open: bool,
|
||||
markdown_file: Option<PathBuf>,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = JiraConfig::load().map_err(|e| format!("Configuration error: {}", e))?;
|
||||
|
@ -386,8 +387,14 @@ pub async fn create(
|
|||
let response =
|
||||
create_jira_issue(&config, &selected_project, &title, &description, &metadata).await?;
|
||||
|
||||
let url = format!("{}/browse/{}", config.url, response.key);
|
||||
|
||||
println!("Successfully created ticket: {}", response.key);
|
||||
println!("URL: {}/browse/{}", config.url, response.key);
|
||||
println!("URL: {}", url);
|
||||
|
||||
if open {
|
||||
open::that(url)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -13,8 +13,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
match cli.command {
|
||||
Commands::Create {
|
||||
project,
|
||||
open,
|
||||
markdown_file,
|
||||
} => cmd::create::create(project, markdown_file).await?,
|
||||
} => cmd::create::create(project, open, markdown_file).await?,
|
||||
Commands::List { json } => cmd::list::list(json).await?,
|
||||
Commands::Init { url, email, token } => {
|
||||
JiraConfig::init(url, email, token).await?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue