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