diff --git a/Cargo.toml b/Cargo.toml index 628ed61f..0a3d8c16 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,8 @@ is-it-maintained-open-issues = { repository = "starship/starship" } maintenance = { status = "actively-developed" } [features] -default = ["battery"] +default = ["battery", "http"] +http = ["reqwest"] [dependencies] clap = "2.33.0" @@ -52,7 +53,7 @@ urlencoding = "1.0.0" open = "1.3.4" # OpenSSL causes problems when building a MUSL release. Opting to use native SSL implementation # see: https://github.com/richfelker/musl-cross-make/issues/65#issuecomment-509790889 -reqwest = { version = "0.10.4", default-features = false, features = ["blocking", "rustls-tls"] } +reqwest = { version = "0.10.4", default-features = false, optional = true, features = ["blocking", "rustls-tls"] } unicode-width = "0.1.7" textwrap = "0.11.0" term_size = "0.3.1" diff --git a/src/bug_report.rs b/src/bug_report.rs index 8e53c4e1..aa268ed7 100644 --- a/src/bug_report.rs +++ b/src/bug_report.rs @@ -1,8 +1,9 @@ use crate::utils::exec_cmd; -use reqwest; + use std::fs; use std::path::PathBuf; +#[cfg(feature = "http")] const GIT_IO_BASE_URL: &str = "https://git.io/"; pub fn create() { @@ -21,14 +22,7 @@ pub fn create() { if open::that(&link).is_ok() { print!("Take a look at your browser. A GitHub issue has been populated with your configuration") } else { - let link = reqwest::blocking::Client::new() - .post(&format!("{}{}", GIT_IO_BASE_URL, "create")) - .form(&[("url", &link)]) - .send() - .and_then(|response| response.text()) - .map(|slug| format!("{}{}", GIT_IO_BASE_URL, slug)) - .unwrap_or(link); - + let link = shorten_link(&link).unwrap_or(link); println!( "Click this link to create a GitHub issue populated with your configuration:\n\n {}", link @@ -36,6 +30,22 @@ pub fn create() { } } +#[cfg(feature = "http")] +fn shorten_link(link: &str) -> Option { + reqwest::blocking::Client::new() + .post(&format!("{}{}", GIT_IO_BASE_URL, "create")) + .form(&[("url", link)]) + .send() + .and_then(|response| response.text()) + .map(|slug| format!("{}{}", GIT_IO_BASE_URL, slug)) + .ok() +} + +#[cfg(not(feature = "http"))] +fn shorten_link(_url: &str) -> Option { + None +} + const UNKNOWN_SHELL: &str = ""; const UNKNOWN_TERMINAL: &str = ""; const UNKNOWN_VERSION: &str = "";