Add progress bars for package creation
This commit is contained in:
parent
e8aa73bf9d
commit
cf9d6aa7e6
95
Cargo.lock
generated
95
Cargo.lock
generated
@ -51,6 +51,12 @@ dependencies = [
|
|||||||
"windows-sys 0.45.0",
|
"windows-sys 0.45.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "arrayvec"
|
||||||
|
version = "0.7.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
@ -221,6 +227,19 @@ dependencies = [
|
|||||||
"windows-sys 0.45.0",
|
"windows-sys 0.45.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "console"
|
||||||
|
version = "0.15.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3d79fbe8970a77e3e34151cc13d3b3e248aa0faaecb9f6091fa07ebefe5ad60"
|
||||||
|
dependencies = [
|
||||||
|
"encode_unicode",
|
||||||
|
"lazy_static",
|
||||||
|
"libc",
|
||||||
|
"unicode-width",
|
||||||
|
"windows-sys 0.42.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation"
|
name = "core-foundation"
|
||||||
version = "0.9.3"
|
version = "0.9.3"
|
||||||
@ -417,6 +436,12 @@ version = "1.8.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "encode_unicode"
|
||||||
|
version = "0.3.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "encoding_rs"
|
name = "encoding_rs"
|
||||||
version = "0.8.32"
|
version = "0.8.32"
|
||||||
@ -593,7 +618,7 @@ checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "hpk"
|
name = "hpk"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.hitchhiker-linux.org/jeang3nie/hpk.git#1160730e1f492c68269d5a9aaef9df4cd97e7c61"
|
source = "git+https://git.hitchhiker-linux.org/jeang3nie/hpk.git#3d0151610d80f5453248ebd8e7e73f7cefd0fc13"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"deku",
|
"deku",
|
||||||
@ -614,6 +639,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"hpk",
|
"hpk",
|
||||||
|
"indicatif",
|
||||||
"package-bootstrap",
|
"package-bootstrap",
|
||||||
"ron",
|
"ron",
|
||||||
]
|
]
|
||||||
@ -739,6 +765,20 @@ dependencies = [
|
|||||||
"hashbrown",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indicatif"
|
||||||
|
version = "0.17.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cef509aa9bc73864d6756f0d34d35504af3cf0844373afe9b8669a5b8005a729"
|
||||||
|
dependencies = [
|
||||||
|
"console",
|
||||||
|
"number_prefix",
|
||||||
|
"portable-atomic",
|
||||||
|
"unicode-segmentation",
|
||||||
|
"unicode-width",
|
||||||
|
"vt100",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "instant"
|
name = "instant"
|
||||||
version = "0.1.12"
|
version = "0.1.12"
|
||||||
@ -917,6 +957,12 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "number_prefix"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.17.1"
|
version = "1.17.1"
|
||||||
@ -1004,6 +1050,12 @@ version = "0.3.26"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
|
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "portable-atomic"
|
||||||
|
version = "0.3.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "26f6a7b87c2e435a3241addceeeff740ff8b7e76b74c13bf9acb17fa454ea00b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro-crate"
|
name = "proc-macro-crate"
|
||||||
version = "1.3.1"
|
version = "1.3.1"
|
||||||
@ -1306,7 +1358,7 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "tar"
|
name = "tar"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.hitchhiker-linux.org/jeang3nie/hpk.git#1160730e1f492c68269d5a9aaef9df4cd97e7c61"
|
source = "git+https://git.hitchhiker-linux.org/jeang3nie/hpk.git#3d0151610d80f5453248ebd8e7e73f7cefd0fc13"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deku",
|
"deku",
|
||||||
"libc",
|
"libc",
|
||||||
@ -1497,6 +1549,12 @@ dependencies = [
|
|||||||
"tinyvec",
|
"tinyvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-segmentation"
|
||||||
|
version = "1.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-width"
|
name = "unicode-width"
|
||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
@ -1533,6 +1591,39 @@ version = "0.9.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vt100"
|
||||||
|
version = "0.15.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "84cd863bf0db7e392ba3bd04994be3473491b31e66340672af5d11943c6274de"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"log",
|
||||||
|
"unicode-width",
|
||||||
|
"vte",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vte"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1aae21c12ad2ec2d168c236f369c38ff332bc1134f7246350dca641437365045"
|
||||||
|
dependencies = [
|
||||||
|
"arrayvec",
|
||||||
|
"utf8parse",
|
||||||
|
"vte_generate_state_changes",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vte_generate_state_changes"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "walkdir"
|
name = "walkdir"
|
||||||
version = "2.3.3"
|
version = "2.3.3"
|
||||||
|
@ -23,6 +23,10 @@ ron = "0.8"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
features = ["mangen"]
|
features = ["mangen"]
|
||||||
|
|
||||||
|
[dependencies.indicatif]
|
||||||
|
version = "0.17"
|
||||||
|
features = ["improved_unicode", "vt100"]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
lto = true
|
lto = true
|
||||||
|
38
src/hpk.rs
38
src/hpk.rs
@ -1,7 +1,10 @@
|
|||||||
|
use std::io::ErrorKind;
|
||||||
|
|
||||||
use {
|
use {
|
||||||
clap::ArgMatches,
|
clap::ArgMatches,
|
||||||
hpk_cli::cli,
|
|
||||||
hpk::{Creator, Dependency, Message, Specs, Version},
|
hpk::{Creator, Dependency, Message, Specs, Version},
|
||||||
|
hpk_cli::cli,
|
||||||
|
indicatif::ProgressBar,
|
||||||
ron::ser::{to_writer_pretty, PrettyConfig},
|
ron::ser::{to_writer_pretty, PrettyConfig},
|
||||||
std::{
|
std::{
|
||||||
env,
|
env,
|
||||||
@ -10,7 +13,8 @@ use {
|
|||||||
fs::File,
|
fs::File,
|
||||||
io::{self, BufWriter},
|
io::{self, BufWriter},
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::mpsc,
|
sync::{mpsc, Mutex},
|
||||||
|
thread,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,18 +69,30 @@ fn create(matches: &ArgMatches) -> Result<(), Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
let creator = Creator::new(&dir, specs)?;
|
let creator = Creator::new(&dir, specs)?;
|
||||||
let (sender, receiver) = mpsc::channel();
|
let (sender, receiver) = mpsc::channel();
|
||||||
creator.create(&outdir, sender)?;
|
let len = creator.len();
|
||||||
for msg in receiver.iter() {
|
let pb = Mutex::new(ProgressBar::new(len as u64));
|
||||||
match msg {
|
let handle = thread::spawn(move || {
|
||||||
Message::MemberAdded(_s) => {}
|
for msg in receiver.iter() {
|
||||||
Message::Success(s) => println!("{s}"),
|
match msg {
|
||||||
Message::Failure(s) => {
|
Message::MemberAdded(_s) => pb.lock().unwrap().inc(1),
|
||||||
eprint!("{s}");
|
Message::Success(_s) => {
|
||||||
return Err(io::Error::new(io::ErrorKind::Other, s).into());
|
let pb = pb.lock().unwrap();
|
||||||
|
pb.inc(1);
|
||||||
|
pb.finish_with_message("done");
|
||||||
|
},
|
||||||
|
Message::Failure(s) => {
|
||||||
|
eprint!("{s}");
|
||||||
|
return Err(io::Error::new(io::ErrorKind::Other, s));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
|
});
|
||||||
|
creator.create(&outdir, sender)?;
|
||||||
|
match handle.join() {
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(e) => Err(io::Error::new(ErrorKind::Other, format!("{e:?}")).into()),
|
||||||
}
|
}
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init(matches: &ArgMatches) -> Result<PathBuf, Box<dyn Error>> {
|
fn init(matches: &ArgMatches) -> Result<PathBuf, Box<dyn Error>> {
|
||||||
|
Loading…
Reference in New Issue
Block a user