Skip to content

Commit

Permalink
Improve UI of pull/push commands
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiimk committed Nov 16, 2020
1 parent a9a0fcc commit 8741ec9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Changed
- Engine errors will not list all relevant log files
- UI improvements

## [0.35.0] - 2020-11-14
### Added
Expand Down
20 changes: 18 additions & 2 deletions kamu-cli/src/commands/push_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct PushCommand {
sync_svc: Rc<RefCell<dyn SyncService>>,
ids: Vec<String>,
remote: Option<String>,
_output_config: OutputConfig,
output_config: OutputConfig,
}

impl PushCommand {
Expand All @@ -35,7 +35,7 @@ impl PushCommand {
sync_svc: sync_svc,
ids: ids.map(|s| s.as_ref().to_owned()).collect(),
remote: remote.map(|v| v.as_ref().to_owned()),
_output_config: output_config.clone(),
output_config: output_config.clone(),
}
}

Expand Down Expand Up @@ -69,6 +69,18 @@ impl Command for PushCommand {

let dataset_ids: Vec<DatasetIDBuf> = self.ids.iter().map(|s| s.parse().unwrap()).collect();

let spinner = if self.output_config.verbosity_level == 0 {
let s = indicatif::ProgressBar::new_spinner();
s.set_style(
indicatif::ProgressStyle::default_spinner().template("{spinner:.cyan} {msg}"),
);
s.set_message("Pushing dataset(s) to a remote");
s.enable_steady_tick(100);
Some(s)
} else {
None
};

let mut updated = 0;
let mut up_to_date = 0;
let mut errors = 0;
Expand All @@ -85,6 +97,10 @@ impl Command for PushCommand {
}
}

if let Some(s) = spinner {
s.finish_and_clear()
}

if updated != 0 {
eprintln!(
"{}",
Expand Down
20 changes: 18 additions & 2 deletions kamu-cli/src/commands/sync_from_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct SyncFromCommand {
sync_svc: Rc<RefCell<dyn SyncService>>,
ids: Vec<String>,
remote: Option<String>,
_output_config: OutputConfig,
output_config: OutputConfig,
}

impl SyncFromCommand {
Expand All @@ -35,7 +35,7 @@ impl SyncFromCommand {
sync_svc: sync_svc,
ids: ids.map(|s| s.as_ref().to_owned()).collect(),
remote: remote.map(|v| v.as_ref().to_owned()),
_output_config: output_config.clone(),
output_config: output_config.clone(),
}
}

Expand Down Expand Up @@ -69,6 +69,18 @@ impl Command for SyncFromCommand {

let dataset_ids: Vec<DatasetIDBuf> = self.ids.iter().map(|s| s.parse().unwrap()).collect();

let spinner = if self.output_config.verbosity_level == 0 {
let s = indicatif::ProgressBar::new_spinner();
s.set_style(
indicatif::ProgressStyle::default_spinner().template("{spinner:.cyan} {msg}"),
);
s.set_message("Pulling dataset(s) from a remote");
s.enable_steady_tick(100);
Some(s)
} else {
None
};

let mut updated = 0;
let mut up_to_date = 0;
let mut errors = 0;
Expand All @@ -85,6 +97,10 @@ impl Command for SyncFromCommand {
}
}

if let Some(s) = spinner {
s.finish_and_clear()
}

if updated != 0 {
eprintln!(
"{}",
Expand Down

0 comments on commit 8741ec9

Please sign in to comment.