mirror of
https://github.com/starship/starship.git
synced 2026-06-23 02:05:51 +07:00
refactor: replace reqwest with ureq (#844)
This commit is contained in:
committed by
Matan Kushner
parent
6a9eaa90b5
commit
d869b3a098
+14
-9
@@ -1,7 +1,8 @@
|
||||
use crate::utils::exec_cmd;
|
||||
use reqwest;
|
||||
use serde_urlencoded;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use ureq;
|
||||
|
||||
const GIT_IO_BASE_URL: &str = "https://git.io/";
|
||||
|
||||
@@ -16,18 +17,22 @@ pub fn create() {
|
||||
starship_config: get_starship_config(),
|
||||
};
|
||||
|
||||
let link = make_github_issue_link(crate_version!(), environment);
|
||||
let mut link = make_github_issue_link(crate_version!(), environment);
|
||||
|
||||
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 data = serde_urlencoded::to_string(&[("url", &link)]);
|
||||
if let Ok(data) = data {
|
||||
let short_link = ureq::post(&format!("{}{}", GIT_IO_BASE_URL, "create"))
|
||||
.set("Content-Type", "application/x-www-form-urlencoded")
|
||||
.send_string(&data)
|
||||
.into_string()
|
||||
.map(|slug| format!("{}{}", GIT_IO_BASE_URL, slug));
|
||||
if let Ok(short_link) = short_link {
|
||||
link = short_link;
|
||||
}
|
||||
}
|
||||
|
||||
println!(
|
||||
"Click this link to create a GitHub issue populated with your configuration:\n\n {}",
|
||||
|
||||
Reference in New Issue
Block a user