Skip to content

Commit

Permalink
update github backend
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Sep 5, 2022
1 parent 224887b commit 506aee7
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/backends/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ GitHub releases
use std::env::{self, consts::EXE_SUFFIX};
use std::path::{Path, PathBuf};

use indicatif::ProgressStyle;
use reqwest::{self, header};

use crate::backends::find_rel_next_link;
Expand Down Expand Up @@ -238,7 +237,8 @@ pub struct UpdateBuilder {
no_confirm: bool,
current_version: Option<String>,
target_version: Option<String>,
progress_style: Option<ProgressStyle>,
progress_template: String,
progress_chars: String,
auth_token: Option<String>,
custom_url: Option<String>,
}
Expand Down Expand Up @@ -346,8 +346,9 @@ impl UpdateBuilder {
}

/// Toggle download progress bar, defaults to `off`.
pub fn set_progress_style(&mut self, progress_style: ProgressStyle) -> &mut Self {
self.progress_style = Some(progress_style);
pub fn set_progress_style(&mut self, progress_template: String, progress_chars: String) -> &mut Self {
self.progress_template = progress_template;
self.progress_chars = progress_chars;
self
}

Expand Down Expand Up @@ -419,7 +420,8 @@ impl UpdateBuilder {
},
target_version: self.target_version.as_ref().map(|v| v.to_owned()),
show_download_progress: self.show_download_progress,
progress_style: self.progress_style.clone(),
progress_template: self.progress_template.clone(),
progress_chars: self.progress_chars.clone(),
show_output: self.show_output,
no_confirm: self.no_confirm,
auth_token: self.auth_token.clone(),
Expand All @@ -442,7 +444,8 @@ pub struct Update {
show_download_progress: bool,
show_output: bool,
no_confirm: bool,
progress_style: Option<ProgressStyle>,
progress_template: String,
progress_chars: String,
auth_token: Option<String>,
custom_url: Option<String>,
}
Expand Down Expand Up @@ -543,8 +546,12 @@ impl ReleaseUpdate for Update {
self.no_confirm
}

fn progress_style(&self) -> Option<ProgressStyle> {
self.progress_style.clone()
fn progress_template(&self) -> String {
self.progress_template.to_owned()
}

fn progress_chars(&self) -> String {
self.progress_chars.to_owned()
}

fn auth_token(&self) -> Option<String> {
Expand All @@ -566,7 +573,8 @@ impl Default for UpdateBuilder {
no_confirm: false,
current_version: None,
target_version: None,
progress_style: None,
progress_template: "[{elapsed_precise}] [{bar:40}] {bytes}/{total_bytes} ({eta}) {msg}".to_string(),
progress_chars: "=>-".to_string(),
auth_token: None,
custom_url: None,
}
Expand Down

0 comments on commit 506aee7

Please sign in to comment.