blob: 57f9d67c6bbca73a7dab27e9916d5dec79e6f835 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
//
// Copyright (c) 2020-2022 science+computing ag and other contributors
//
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
//
// SPDX-License-Identifier: EPL-2.0
//
use indicatif::*;
use getset::CopyGetters;
#[derive(Clone, Debug, CopyGetters)]
pub struct ProgressBars {
bar_template: String,
#[getset(get_copy = "pub")]
hide: bool,
}
impl ProgressBars {
pub fn setup(bar_template: String, hide: bool) -> Self {
ProgressBars {
bar_template,
hide,
}
}
pub fn bar(&self) -> ProgressBar {
if self.hide {
ProgressBar::hidden()
} else {
let b = ProgressBar::new(1);
b.set_style(ProgressStyle::default_bar().template(&self.bar_template));
b
}
}
}
|