mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-28 15:56:28 +00:00
feat: make reqwest an optional dependency (#979)
This commit is contained in:
parent
7f82dd66ed
commit
d894ef5ad3
@ -21,7 +21,8 @@ is-it-maintained-open-issues = { repository = "starship/starship" }
|
|||||||
maintenance = { status = "actively-developed" }
|
maintenance = { status = "actively-developed" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["battery"]
|
default = ["battery", "http"]
|
||||||
|
http = ["reqwest"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.33.0"
|
clap = "2.33.0"
|
||||||
@ -52,7 +53,7 @@ urlencoding = "1.0.0"
|
|||||||
open = "1.3.4"
|
open = "1.3.4"
|
||||||
# OpenSSL causes problems when building a MUSL release. Opting to use native SSL implementation
|
# 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
|
# 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"
|
unicode-width = "0.1.7"
|
||||||
textwrap = "0.11.0"
|
textwrap = "0.11.0"
|
||||||
term_size = "0.3.1"
|
term_size = "0.3.1"
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
use crate::utils::exec_cmd;
|
use crate::utils::exec_cmd;
|
||||||
use reqwest;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
#[cfg(feature = "http")]
|
||||||
const GIT_IO_BASE_URL: &str = "https://git.io/";
|
const GIT_IO_BASE_URL: &str = "https://git.io/";
|
||||||
|
|
||||||
pub fn create() {
|
pub fn create() {
|
||||||
@ -21,14 +22,7 @@ pub fn create() {
|
|||||||
if open::that(&link).is_ok() {
|
if open::that(&link).is_ok() {
|
||||||
print!("Take a look at your browser. A GitHub issue has been populated with your configuration")
|
print!("Take a look at your browser. A GitHub issue has been populated with your configuration")
|
||||||
} else {
|
} else {
|
||||||
let link = reqwest::blocking::Client::new()
|
let link = shorten_link(&link).unwrap_or(link);
|
||||||
.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);
|
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"Click this link to create a GitHub issue populated with your configuration:\n\n {}",
|
"Click this link to create a GitHub issue populated with your configuration:\n\n {}",
|
||||||
link
|
link
|
||||||
@ -36,6 +30,22 @@ pub fn create() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "http")]
|
||||||
|
fn shorten_link(link: &str) -> Option<String> {
|
||||||
|
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<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
const UNKNOWN_SHELL: &str = "<unknown shell>";
|
const UNKNOWN_SHELL: &str = "<unknown shell>";
|
||||||
const UNKNOWN_TERMINAL: &str = "<unknown terminal>";
|
const UNKNOWN_TERMINAL: &str = "<unknown terminal>";
|
||||||
const UNKNOWN_VERSION: &str = "<unknown version>";
|
const UNKNOWN_VERSION: &str = "<unknown version>";
|
||||||
|
Loading…
Reference in New Issue
Block a user