Create `pijul-interaction` crate
Dependencies
- [2]
DVBSW7SIBump dependencies with minor-level changes - [3]
JMOHVR5EBump edition to 2021 - [4]
TNN56XYKlibpijul alpha.43 - [5]
EJ7TFFOWRe-adding Cargo.lock - [6]
SXEYMYF7Fixing the bad changes in history (unfortunately, by rebooting). - [7]
RDQYEED2Fixing versions - [8]
SGXOEWHUAdding a patched chardetng (temporarily) - [9]
SYP2J7VCRemoving the progressbar member from the workspace - [10]
BNPSVXICFriendlier progress bars - [*]
STG7MO5MVersion bump - [*]
ENWJBQGQFixing a deprecation warning in ed25519_dalek.
Change contents
- edit in Cargo.lock at line 126
dependencies = ["backtrace",] - edit in Cargo.lock at line 1479
][[package]]name = "indicatif"version = "0.17.5"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "8ff8cc23a7393a397ed1d7f56e6365cba772aba9f9912ab968b03043c395d057"dependencies = ["console","instant","number_prefix","portable-atomic","unicode-segmentation","unicode-width", - edit in Cargo.lock at line 1974
[[package]]name = "number_prefix"version = "0.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" - edit in Cargo.lock at line 2207
"pijul-interaction", - edit in Cargo.lock at line 2219
"terminal_size", - edit in Cargo.lock at line 2228
][[package]]name = "pijul-interaction"version = "0.0.1"dependencies = ["anyhow","indicatif","lazy_static 1.4.0", - edit in Cargo.lock at line 2282
[[package]]name = "portable-atomic"version = "1.4.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d220334a184db82b31b83f5ff093e3315280fb2b6bbc032022b2304a509aab7a" - edit in Cargo.lock at line 2923
][[package]]name = "terminal_size"version = "0.1.17"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df"dependencies = ["libc","winapi", - edit in Cargo.lock at line 3289
name = "unicode-segmentation"version = "1.10.1"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"[[package]] - replacement in Cargo.toml at line 2
members = [ "pijul-macros", "pijul", "libpijul" ]members = [ "pijul-macros", "pijul", "libpijul", "pijul-interaction" ] - file addition: pijul-interaction[13.2]
- file addition: src[0.1206]
- file addition: progress.rs[0.1223]
use std::time::Duration;use indicatif::MultiProgress;use lazy_static::lazy_static;use indicatif::ProgressStyle;lazy_static! {static ref MULTI_PROGRESS: MultiProgress = MultiProgress::new();}pub const DOWNLOAD_MESSAGE: &str = "Downloading changes";pub const APPLY_MESSAGE: &str = "Applying changes";pub const UPLOAD_MESSAGE: &str = "Uploading changes";pub const COMPLETE_MESSAGE: &str = "Completing changes";pub const OUTPUT_MESSAGE: &str = "Outputting repository";#[derive(Clone, Debug)]pub struct ProgressBar(Option<indicatif::ProgressBar>);impl Drop for ProgressBar {fn drop(&mut self) {// Make sure the progress bar doesn't disappear after completionif let Some(progress_bar) = &self.0 {progress_bar.finish();}}}impl ProgressBar {pub fn new(len: u64, message: &str) -> Result<Self, anyhow::Error> {let style =ProgressStyle::with_template("{msg:<20} [{bar:50}] {pos}/{len} [{elapsed_precise}]")?.progress_chars("=> ");let progress_bar = indicatif::ProgressBar::new(len).with_style(style).with_message(message.to_owned());MULTI_PROGRESS.add(progress_bar.clone());progress_bar.enable_steady_tick(Duration::from_millis(15));Ok(Self(Some(progress_bar)))}pub fn hidden() -> Self {Self(None)}pub fn inc(&self, delta: u64) {if let Some(progress) = self.0.clone() {progress.inc(delta);}}pub fn inner(&self) -> Option<indicatif::ProgressBar> {self.0.clone()}}#[derive(Clone, Debug)]pub struct Spinner(indicatif::ProgressBar);impl Drop for Spinner {fn drop(&mut self) {// Make sure the spinner doesn't disappear after completionself.finish().unwrap();}}impl Spinner {pub fn new(message: &str) -> Result<Self, anyhow::Error> {let style = ProgressStyle::with_template("{msg}{spinner}")?.tick_strings(&[". ", ".. ", "...", " "]);let spinner = indicatif::ProgressBar::new_spinner().with_style(style).with_message(message.to_owned());spinner.enable_steady_tick(Duration::from_millis(200));MULTI_PROGRESS.add(spinner.clone());Ok(Self(spinner))}pub fn finish(&self) -> Result<(), anyhow::Error> {self.0.set_style(ProgressStyle::with_template("{msg}")?);self.0.finish_with_message(format!("{}... done!", self.0.message()));Ok(())}} - file addition: lib.rs[0.1223]
pub mod progress; - file addition: Cargo.toml[0.1206]
[package]name = "pijul-interaction"description = "Human friendly input/output (progress bars, passwords etc) for contexts such as terminals or GUIs"version = "0.0.1"authors = ["Finchie"]edition = "2021"repository = "https://nest.pijul.com/pijul/pijul"license = "GPL-2.0"include = [ "Cargo.toml", "src" ][dependencies]anyhow = { version = "1.0", features = ["backtrace"] }indicatif = { version = "0.17", features = ["improved_unicode"] }lazy_static = "1.4"