Skip to content

Commit

Permalink
use const DEFAULT_PROGRESS_TEMPLATE & DEFAULT_PROGRESS_CHARS
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Sep 5, 2022
1 parent 3948830 commit ada335e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/backends/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::{
errors::*,
get_target,
update::{Release, ReleaseAsset, ReleaseUpdate},
DEFAULT_PROGRESS_CHARS, DEFAULT_PROGRESS_TEMPLATE,
};

impl ReleaseAsset {
Expand Down Expand Up @@ -345,7 +346,7 @@ impl UpdateBuilder {
self
}

/// Toggle download progress bar, defaults to `off`.
/// Set download progress style.
pub fn set_progress_style(
&mut self,
progress_template: String,
Expand Down Expand Up @@ -577,9 +578,8 @@ impl Default for UpdateBuilder {
no_confirm: false,
current_version: None,
target_version: None,
progress_template: "[{elapsed_precise}] [{bar:40}] {bytes}/{total_bytes} ({eta}) {msg}"
.to_string(),
progress_chars: "=>-".to_string(),
progress_template: DEFAULT_PROGRESS_TEMPLATE.to_string(),
progress_chars: DEFAULT_PROGRESS_CHARS.to_string(),
auth_token: None,
custom_url: None,
}
Expand Down
6 changes: 3 additions & 3 deletions src/backends/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::{
errors::*,
get_target,
update::{Release, ReleaseAsset, ReleaseUpdate},
DEFAULT_PROGRESS_CHARS, DEFAULT_PROGRESS_TEMPLATE,
};

impl ReleaseAsset {
Expand Down Expand Up @@ -549,9 +550,8 @@ impl Default for UpdateBuilder {
no_confirm: false,
current_version: None,
target_version: None,
progress_template: "[{elapsed_precise}] [{bar:40}] {bytes}/{total_bytes} ({eta}) {msg}"
.to_string(),
progress_chars: "=>-".to_string(),
progress_template: DEFAULT_PROGRESS_TEMPLATE.to_string(),
progress_chars: DEFAULT_PROGRESS_CHARS.to_string(),
auth_token: None,
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/backends/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
get_target,
update::{Release, ReleaseAsset, ReleaseUpdate},
version::bump_is_greater,
DEFAULT_PROGRESS_CHARS, DEFAULT_PROGRESS_TEMPLATE,
};
use quick_xml::events::Event;
use quick_xml::Reader;
Expand Down Expand Up @@ -174,9 +175,8 @@ impl Default for UpdateBuilder {
no_confirm: false,
current_version: None,
target_version: None,
progress_template: "[{elapsed_precise}] [{bar:40}] {bytes}/{total_bytes} ({eta}) {msg}"
.to_string(),
progress_chars: "=>-".to_string(),
progress_template: DEFAULT_PROGRESS_TEMPLATE.to_string(),
progress_chars: DEFAULT_PROGRESS_CHARS.to_string(),
auth_token: None,
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ pub mod errors;
pub mod update;
pub mod version;

pub const DEFAULT_PROGRESS_TEMPLATE: &str =
"[{elapsed_precise}] [{bar:40}] {bytes}/{total_bytes} ({eta}) {msg}";
pub const DEFAULT_PROGRESS_CHARS: &str = "=>-";

use errors::*;

/// Get the current target triple.
Expand Down Expand Up @@ -617,9 +621,8 @@ impl Download {
show_progress: false,
url: url.to_owned(),
headers: reqwest::header::HeaderMap::new(),
progress_template: "[{elapsed_precise}] [{bar:40}] {bytes}/{total_bytes} ({eta}) {msg}"
.to_string(),
progress_chars: "=>-".to_string(),
progress_template: DEFAULT_PROGRESS_TEMPLATE.to_string(),
progress_chars: DEFAULT_PROGRESS_CHARS.to_string(),
}
}

Expand Down

0 comments on commit ada335e

Please sign in to comment.