Add no-progress-bars feature so other packages can hide them (#66)
This commit is contained in:
@@ -32,4 +32,5 @@ features = ["extension-module","abi3-py36"]
|
||||
|
||||
[features]
|
||||
default = ["jemalloc"]
|
||||
jemalloc = []
|
||||
jemalloc = []
|
||||
no-progress-bars = []
|
||||
|
||||
@@ -14,7 +14,7 @@ postgres-openssl = "0.5.0"
|
||||
jemallocator = "0.3.2"
|
||||
rand = "0.8.0"
|
||||
serial_test = "0.5.1"
|
||||
synapse_compress_state = { path = "../" }
|
||||
synapse_compress_state = { path = "../", features = ["no-progress-bars"] }
|
||||
env_logger = { version = "0.9.0", git = "https://github.com/TilCreator/env_logger", branch = "fix_pipe" }
|
||||
log = "0.4.14"
|
||||
log-panics = "2.0.0"
|
||||
|
||||
@@ -12,7 +12,7 @@ openssl = "0.10.32"
|
||||
postgres = "0.19.0"
|
||||
postgres-openssl = "0.5.0"
|
||||
rand = "0.8.0"
|
||||
synapse_compress_state = { path = "../" }
|
||||
synapse_compress_state = { path = "../", features = ["no-progress-bars"] }
|
||||
auto_compressor = { path = "../auto_compressor/" }
|
||||
env_logger = "0.9.0"
|
||||
log = "0.4.14"
|
||||
|
||||
@@ -181,7 +181,12 @@ impl<'a> Compressor<'a> {
|
||||
panic!("Can only call `create_new_tree` once");
|
||||
}
|
||||
|
||||
let pb = ProgressBar::new(self.original_state_map.len() as u64);
|
||||
let pb: ProgressBar;
|
||||
if cfg!(feature = "no-progress-bars") {
|
||||
pb = ProgressBar::hidden();
|
||||
} else {
|
||||
pb = ProgressBar::new(self.original_state_map.len() as u64);
|
||||
}
|
||||
pb.set_style(
|
||||
ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"),
|
||||
);
|
||||
|
||||
@@ -373,7 +373,12 @@ fn get_initial_data_from_db(
|
||||
// Copy the data from the database into a map
|
||||
let mut state_group_map: BTreeMap<i64, StateGroupEntry> = BTreeMap::new();
|
||||
|
||||
let pb = ProgressBar::new_spinner();
|
||||
let pb: ProgressBar;
|
||||
if cfg!(feature = "no-progress-bars") {
|
||||
pb = ProgressBar::hidden();
|
||||
} else {
|
||||
pb = ProgressBar::new_spinner();
|
||||
}
|
||||
pb.set_style(
|
||||
ProgressStyle::default_spinner().template("{spinner} [{elapsed}] {pos} rows retrieved"),
|
||||
);
|
||||
@@ -533,7 +538,12 @@ pub fn send_changes_to_db(
|
||||
println!("Writing changes...");
|
||||
|
||||
// setup the progress bar
|
||||
let pb = ProgressBar::new(old_map.len() as u64);
|
||||
let pb: ProgressBar;
|
||||
if cfg!(feature = "no-progress-bars") {
|
||||
pb = ProgressBar::hidden();
|
||||
} else {
|
||||
pb = ProgressBar::new(old_map.len() as u64);
|
||||
}
|
||||
pb.set_style(
|
||||
ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"),
|
||||
);
|
||||
|
||||
14
src/lib.rs
14
src/lib.rs
@@ -487,7 +487,12 @@ fn output_sql(
|
||||
|
||||
println!("Writing changes...");
|
||||
|
||||
let pb = ProgressBar::new(old_map.len() as u64);
|
||||
let pb: ProgressBar;
|
||||
if cfg!(feature = "no-progress-bars") {
|
||||
pb = ProgressBar::hidden();
|
||||
} else {
|
||||
pb = ProgressBar::new(old_map.len() as u64);
|
||||
}
|
||||
pb.set_style(
|
||||
ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"),
|
||||
);
|
||||
@@ -597,7 +602,12 @@ fn check_that_maps_match(
|
||||
) {
|
||||
println!("Checking that state maps match...");
|
||||
|
||||
let pb = ProgressBar::new(old_map.len() as u64);
|
||||
let pb: ProgressBar;
|
||||
if cfg!(feature = "no-progress-bars") {
|
||||
pb = ProgressBar::hidden();
|
||||
} else {
|
||||
pb = ProgressBar::new(old_map.len() as u64);
|
||||
}
|
||||
pb.set_style(
|
||||
ProgressStyle::default_bar().template("[{elapsed_precise}] {bar} {pos}/{len} {msg}"),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user