Skip to content

Commit

Permalink
Update frames.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Dec 19, 2024
1 parent bd717c6 commit 0511b0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 10 additions & 6 deletions crates/cli/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,25 @@ pub fn create_progress_bar_download_style() -> ProgressStyle {
.unwrap()
}

pub fn create_progress_spinner_style() -> ProgressStyle {
let mut chars = vec![];
pub fn create_progress_loader_frames() -> Vec<String> {
let mut frames = vec![];

for i in 1..=20 {
if i == 20 {
chars.push("━".repeat(20));
frames.push("━".repeat(20));
} else {
chars.push(format!("{}╾{}", "━".repeat(i - 1), " ".repeat(20 - i)));
frames.push(format!("{}╾{}", "━".repeat(i - 1), " ".repeat(20 - i)));
}
}

let chars = chars.iter().map(|c| c.as_str()).collect::<Vec<_>>();
frames
}
pub fn create_progress_spinner_style() -> ProgressStyle {
let frames = create_progress_loader_frames();
let frames = frames.iter().map(|f| f.as_str()).collect::<Vec<_>>();

ProgressStyle::default_spinner()
.tick_strings(&chars)
.tick_strings(&frames)
.template(format_template_styles("{prefix} {spinner:20.183/239} | {msg}").as_str())
.unwrap()
}
Expand Down
6 changes: 5 additions & 1 deletion crates/cli/src/session.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::app::{App as CLI, Commands};
use crate::commands::clean::{internal_clean, CleanArgs};
use crate::helpers::create_progress_loader_frames;
use crate::systems::*;
use crate::utils::progress_instance::ProgressInstance;
use crate::utils::tool_record::ToolRecord;
Expand Down Expand Up @@ -42,8 +43,11 @@ pub struct ProtoSession {

impl ProtoSession {
pub fn new(cli: CLI) -> Self {
let mut theme = ConsoleTheme::branded(style_to_color(Style::Shell));
theme.progress_loader_frames = create_progress_loader_frames();

let mut console = Console::<EmptyReporter>::new(false);
console.set_theme(ConsoleTheme::branded(style_to_color(Style::Shell)));
console.set_theme(theme);
console.set_reporter(EmptyReporter);

Self {
Expand Down

0 comments on commit 0511b0a

Please sign in to comment.