Added value hints for cli
This commit is contained in:
parent
efe77b97d8
commit
4b7f5afa56
11
src/hpk.rs
11
src/hpk.rs
@ -17,6 +17,8 @@ use {
|
||||
},
|
||||
};
|
||||
|
||||
static TEMPLATE: &str = "[ {prefix} ] {wide_bar}{pos:>5.cyan}/{len:5.green}{msg:>30}";
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let matches = cli().get_matches();
|
||||
match matches.subcommand() {
|
||||
@ -70,10 +72,7 @@ fn create(matches: &ArgMatches) -> Result<(), Box<dyn Error>> {
|
||||
let (sender, receiver) = mpsc::channel();
|
||||
let len = creator.len();
|
||||
let pb = ProgressBar::new(len as u64);
|
||||
pb.set_style(
|
||||
ProgressStyle::with_template("[ {prefix} ] {wide_bar}{pos:>5.cyan}/{len:5.green}{msg:>30}")
|
||||
.unwrap(),
|
||||
);
|
||||
pb.set_style(ProgressStyle::with_template(TEMPLATE).unwrap());
|
||||
pb.set_prefix("Adding files");
|
||||
pb.println(format!(
|
||||
"Creating package {}-{}_{}.tar.zst",
|
||||
@ -85,7 +84,7 @@ fn create(matches: &ArgMatches) -> Result<(), Box<dyn Error>> {
|
||||
Message::MemberAdded(s) => {
|
||||
pb.set_message(s.split('/').last().unwrap().to_string());
|
||||
pb.inc(1);
|
||||
},
|
||||
}
|
||||
Message::Success(_s) => {
|
||||
pb.inc(1);
|
||||
pb.finish_and_clear();
|
||||
@ -103,7 +102,7 @@ fn create(matches: &ArgMatches) -> Result<(), Box<dyn Error>> {
|
||||
Ok(_) => {
|
||||
println!("Package created successfully");
|
||||
Ok(())
|
||||
},
|
||||
}
|
||||
Err(e) => Err(io::Error::new(ErrorKind::Other, format!("{e:?}")).into()),
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ fn create() -> Command {
|
||||
.args([
|
||||
Arg::new("directory")
|
||||
.help("the directory where the files are located")
|
||||
.value_hint(ValueHint::DirPath)
|
||||
.required(true)
|
||||
.num_args(1),
|
||||
Arg::new("output")
|
||||
@ -37,6 +38,7 @@ fn create() -> Command {
|
||||
.help("path to the package specs file in `ron` format")
|
||||
.short('s')
|
||||
.long("specs")
|
||||
.value_hint(ValueHint::FilePath)
|
||||
.conflicts_with_all(["name", "package-version", "release", "dependencies"])
|
||||
.num_args(1),
|
||||
Arg::new("name")
|
||||
|
Loading…
Reference in New Issue
Block a user