feat(config): create a proper config file with proper settings manipulation
This commit is contained in:
@@ -42,12 +42,19 @@ impl ApiBuilder {
|
||||
}
|
||||
|
||||
pub fn set_url(&mut self, method: Method, url: &str) -> &mut ApiBuilder {
|
||||
self.request = Some(self.client.request(method, url));
|
||||
let mut new_url = url.to_owned();
|
||||
if let Some(active) = config::get_core("force_insecure") {
|
||||
if active == "true" {
|
||||
new_url = url.replace("https", "http");
|
||||
}
|
||||
}
|
||||
|
||||
self.request = Some(self.client.request(method, new_url));
|
||||
self
|
||||
}
|
||||
|
||||
pub fn build_request(&mut self, method: Method, path: &str) -> &mut ApiBuilder {
|
||||
let remote = match config::get("remote") {
|
||||
let remote = match config::get_remote("origin") {
|
||||
Some(r) => r,
|
||||
None => {
|
||||
eprintln!("fatal: unable to find a remote");
|
||||
@@ -64,8 +71,8 @@ impl ApiBuilder {
|
||||
if path != "/" {
|
||||
url.push_str(path);
|
||||
}
|
||||
self.request = Some(self.client.request(method, url));
|
||||
self
|
||||
|
||||
self.set_url(method, &url)
|
||||
}
|
||||
|
||||
pub fn set_req(&mut self, meth: Method, p: &str, api_props: &ApiProps) -> &mut ApiBuilder {
|
||||
@@ -79,8 +86,8 @@ impl ApiBuilder {
|
||||
if p != "/" {
|
||||
url.push_str(p);
|
||||
}
|
||||
self.request = Some(self.client.request(meth, url));
|
||||
self
|
||||
|
||||
self.set_url(meth, &url)
|
||||
}
|
||||
|
||||
pub fn set_basic_auth(&mut self, login: String, pwd: String) -> &mut ApiBuilder {
|
||||
|
||||
@@ -24,7 +24,7 @@ impl Copy {
|
||||
pub fn set_url_copy(&mut self, url: &str, destination: &str) -> &mut Copy {
|
||||
self.api_builder.build_request(Method::from_bytes(b"COPY").unwrap(), url);
|
||||
|
||||
let remote = match config::get("remote") {
|
||||
let remote = match config::get_remote("origin") {
|
||||
Some(r) => r,
|
||||
None => {
|
||||
eprintln!("fatal: unable to find a remote");
|
||||
|
||||
@@ -25,7 +25,7 @@ impl Move {
|
||||
pub fn set_url_move(&mut self, url: &str, destination: &str) -> &mut Move {
|
||||
self.api_builder.build_request(Method::from_bytes(b"MOVE").unwrap(), url);
|
||||
|
||||
let remote = match config::get("remote") {
|
||||
let remote = match config::get_remote("origin") {
|
||||
Some(r) => r,
|
||||
None => {
|
||||
eprintln!("fatal: unable to find a remote");
|
||||
|
||||
@@ -67,7 +67,7 @@ impl ApiCall for ReqProps {
|
||||
}
|
||||
|
||||
fn set_url(&mut self, url: &str) -> &mut ReqProps {
|
||||
let remote = match config::get("remote") {
|
||||
let remote = match config::get_remote("origin") {
|
||||
Some(r) => r,
|
||||
None => {
|
||||
eprintln!("fatal: unable to find a remote");
|
||||
|
||||
@@ -39,7 +39,7 @@ impl RequestManager {
|
||||
{
|
||||
if self.host.is_none()
|
||||
{
|
||||
let remote = match config::get("remote") {
|
||||
let remote = match config::get_remote("origin") {
|
||||
Some(r) => r,
|
||||
None => {
|
||||
// todo ask user instead
|
||||
|
||||
Reference in New Issue
Block a user