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
31
Cargo.lock
generated
31
Cargo.lock
generated
|
@ -820,6 +820,25 @@ version = "2.11.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130"
|
||||
|
||||
[[package]]
|
||||
name = "is-docker"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is-wsl"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5"
|
||||
dependencies = [
|
||||
"is-docker",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
|
@ -840,6 +859,7 @@ dependencies = [
|
|||
"config",
|
||||
"directories",
|
||||
"gray_matter",
|
||||
"open",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
@ -977,6 +997,17 @@ version = "1.20.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||
|
||||
[[package]]
|
||||
name = "open"
|
||||
version = "5.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2483562e62ea94312f3576a7aca397306df7990b8d89033e18766744377ef95"
|
||||
dependencies = [
|
||||
"is-wsl",
|
||||
"libc",
|
||||
"pathdiff",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.10.68"
|
||||
|
|
|
@ -14,4 +14,5 @@ toml = "0.8"
|
|||
config = "0.15"
|
||||
directories = "6.0"
|
||||
tempfile = "3.8"
|
||||
gray_matter = { version = "0.2", default-features = false, features = ["toml"] }
|
||||
gray_matter = { version = "0.2", default-features = false, features = ["toml"] }
|
||||
open = "5.2"
|
|
@ -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…
Reference in a new issue