diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-02-16 09:41:47 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-02-16 10:57:25 +0200 |
commit | c714af9e675fe5762914c28a566e679a98a417ab (patch) | |
tree | 9c091f8fdc6a24b1e6d37af999c74b6d82dae569 /src | |
parent | f9f047dc18763bd37d2cf6cbd47769f7e91f976b (diff) | |
download | obnam2-c714af9e675fe5762914c28a566e679a98a417ab.tar.gz |
refactor: split BackupProgress into initial, increemental variants
This makes it possible to later have different progress bars for
initial and incremental backup runs. However, for now the bars are
identical.
Diffstat (limited to 'src')
-rw-r--r-- | src/backup_progress.rs | 21 | ||||
-rw-r--r-- | src/backup_run.rs | 2 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/backup_progress.rs b/src/backup_progress.rs index 6c1d3e6..d924ce1 100644 --- a/src/backup_progress.rs +++ b/src/backup_progress.rs @@ -6,7 +6,26 @@ pub struct BackupProgress { } impl BackupProgress { - pub fn new() -> Self { + pub fn initial() -> Self { + let progress = if true { + ProgressBar::new(0) + } else { + ProgressBar::hidden() + }; + let parts = vec![ + "{wide_bar}", + "elapsed: {elapsed}", + "files: {pos}/{len}", + "current: {wide_msg}", + "{spinner}", + ]; + progress.set_style(ProgressStyle::default_bar().template(&parts.join("\n"))); + progress.enable_steady_tick(100); + + Self { progress } + } + + pub fn incremental() -> Self { let progress = if true { ProgressBar::new(0) } else { diff --git a/src/backup_run.rs b/src/backup_run.rs index 7bb4440..91e06f0 100644 --- a/src/backup_run.rs +++ b/src/backup_run.rs @@ -34,7 +34,7 @@ impl BackupRun { pub fn new(config: &ClientConfig) -> BackupResult<Self> { let client = BackupClient::new(config)?; let policy = BackupPolicy::new(); - let progress = BackupProgress::new(); + let progress = BackupProgress::initial(); Ok(Self { client, policy, |