-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(actions): add spinner for
run
action, improve styling a bit
- Loading branch information
Showing
6 changed files
with
139 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ pub mod fs; | |
pub mod manifest; | ||
pub mod path; | ||
pub mod repository; | ||
pub mod spinner; | ||
pub mod unpacker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use std::time::Duration; | ||
|
||
use indicatif::{ProgressBar, ProgressStyle}; | ||
|
||
/// Small wrapper around the `indicatif` spinner. | ||
pub struct Spinner { | ||
spinner: ProgressBar, | ||
} | ||
|
||
impl Spinner { | ||
/// Creates a new spinner. | ||
pub fn new() -> Self { | ||
let style = ProgressStyle::default_spinner().tick_chars("⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋·"); | ||
let spinner = ProgressBar::new_spinner(); | ||
|
||
spinner.set_style(style); | ||
spinner.enable_steady_tick(Duration::from_millis(80)); | ||
|
||
Self { spinner } | ||
} | ||
|
||
/// Sets the message of the spinner. | ||
pub fn set_message<S>(&self, message: S) | ||
where | ||
S: Into<String> + AsRef<str>, | ||
{ | ||
self.spinner.set_message(message.into()); | ||
} | ||
|
||
/// Stops the spinner. | ||
pub fn stop(&self) { | ||
self.spinner.finish(); | ||
} | ||
|
||
/// Stops the spinner with the message. | ||
pub fn stop_with_message<S>(&self, message: S) | ||
where | ||
S: Into<String> + AsRef<str>, | ||
{ | ||
self.spinner.finish_with_message(message.into()); | ||
} | ||
|
||
/// Stops the spinner and clears the message. | ||
pub fn stop_with_clear(&self) { | ||
self.spinner.finish_and_clear(); | ||
} | ||
} | ||
|
||
impl Default for Spinner { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} |