From a395052f7c226a934cf1b0d75294b1a3146cbeae Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Tue, 7 Apr 2020 22:08:37 -0700 Subject: [PATCH] Deduplicate progress style string type: reform --- src/consts.rs | 4 ++++ src/subcommand/torrent/create/create_content.rs | 5 +---- src/subcommand/torrent/verify.rs | 5 +---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/consts.rs b/src/consts.rs index 153877f..8495fa2 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -61,6 +61,10 @@ pub(crate) const TICK_CHARS: &str = concat!( "⢸⢹⢺⢻⢼⢽⢾⢿⣸⣹⣺⣻⣼⣽⣾⣿", // 0b1111---- ); +pub(crate) const PROGRESS_STYLE: &str = "{spinner:.green} ⟪{elapsed_precise}⟫ ⟦{bar:.cyan}⟧ \ + {binary_bytes}/{binary_total_bytes} \ + ⟨{binary_bytes_per_sec}, {eta}⟩"; + pub(crate) const VERSION: &str = concat!("v", env!("CARGO_PKG_VERSION")); pub(crate) const VERSION_MESSAGE: &str = "Print version number."; diff --git a/src/subcommand/torrent/create/create_content.rs b/src/subcommand/torrent/create/create_content.rs index 17cc1c3..664fda6 100644 --- a/src/subcommand/torrent/create/create_content.rs +++ b/src/subcommand/torrent/create/create_content.rs @@ -38,10 +38,7 @@ impl CreateContent { .unwrap_or_else(|| PieceLengthPicker::from_content_size(files.total_size())); let style = ProgressStyle::default_bar() - .template( - "{spinner:.green} ⟪{elapsed_precise}⟫ ⟦{bar:40.cyan}⟧ \ - {binary_bytes}/{binary_total_bytes} ⟨{binary_bytes_per_sec}, {eta}⟩", - ) + .template(consts::PROGRESS_STYLE) .tick_chars(consts::TICK_CHARS) .progress_chars(consts::PROGRESS_CHARS); diff --git a/src/subcommand/torrent/verify.rs b/src/subcommand/torrent/verify.rs index 4175f9f..f053657 100644 --- a/src/subcommand/torrent/verify.rs +++ b/src/subcommand/torrent/verify.rs @@ -54,10 +54,7 @@ impl Verify { let progress_bar = if env.err().is_styled_term() { let style = ProgressStyle::default_bar() - .template( - "{spinner:.green} ⟪{elapsed_precise}⟫ ⟦{bar:40.cyan}⟧ \ - {binary_bytes}/{binary_total_bytes} ⟨{binary_bytes_per_sec}, {eta}⟩", - ) + .template(consts::PROGRESS_STYLE) .tick_chars(consts::TICK_CHARS) .progress_chars(consts::PROGRESS_CHARS);