Update package-bootstrap crate

This commit is contained in:
Nathan Fisher 2023-04-05 22:37:25 -04:00
parent 1e101f7e70
commit c5450c34ef
5 changed files with 52 additions and 16 deletions

22
Cargo.lock generated
View File

@ -647,13 +647,13 @@ dependencies = [
[[package]] [[package]]
name = "io-lifetimes" name = "io-lifetimes"
version = "1.0.9" version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220"
dependencies = [ dependencies = [
"hermit-abi 0.3.1", "hermit-abi 0.3.1",
"libc", "libc",
"windows-sys 0.45.0", "windows-sys 0.48.0",
] ]
[[package]] [[package]]
@ -700,9 +700,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.140" version = "0.2.141"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5"
[[package]] [[package]]
name = "link-cplusplus" name = "link-cplusplus"
@ -802,8 +802,7 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]] [[package]]
name = "package-bootstrap" name = "package-bootstrap"
version = "0.1.2" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://codeberg.org/jeang3nie/package-bootstrap.git#10cd1f3b5c79c05e3fca86fc7145562ae29d0962"
checksum = "b4d7e537b8f7223f557d50baca1d88421c30ff13fa58868c2e80254e9ea671a1"
dependencies = [ dependencies = [
"clap", "clap",
"clap_complete", "clap_complete",
@ -1464,6 +1463,15 @@ dependencies = [
"windows-targets 0.42.2", "windows-targets 0.42.2",
] ]
[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets 0.48.0",
]
[[package]] [[package]]
name = "windows-targets" name = "windows-targets"
version = "0.42.2" version = "0.42.2"

View File

@ -20,7 +20,7 @@ hpk = { git = "https://git.hitchhiker-linux.org/jeang3nie/hpk.git" }
ron = "0.8" ron = "0.8"
[dependencies.package-bootstrap] [dependencies.package-bootstrap]
version = "0.1" version = "0.2"
features = ["mangen"] features = ["mangen"]
[dependencies.indicatif] [dependencies.indicatif]

View File

@ -25,13 +25,13 @@ fn main() -> Result<(), Box<dyn Error>> {
let outdir = matches.get_one::<String>("output").unwrap().to_string(); let outdir = matches.get_one::<String>("output").unwrap().to_string();
let outdir = PathBuf::from(&outdir); let outdir = PathBuf::from(&outdir);
let arch = matches.get_one::<String>("arch").map(|x| x.to_string()); let arch = matches.get_one::<String>("arch").map(|x| x.to_string());
Bootstrap::new("hpk", cli()).install(&outdir, arch, 8)?; Bootstrap::new("hpk", cli(), &outdir).install(arch, 8)?;
Bootstrap::new("hpk-init", hpk_cli::init()).manpage(outdir.as_path(), 8)?; Bootstrap::new("hpk-init", hpk_cli::init(), &outdir).manpage(8)?;
Bootstrap::new("hpk-create", hpk_cli::create()).manpage(outdir.as_path(), 8)?; Bootstrap::new("hpk-create", hpk_cli::create(), &outdir).manpage(8)?;
Bootstrap::new("hpk-install", hpk_cli::install()).manpage(outdir.as_path(), 8)?; Bootstrap::new("hpk-install", hpk_cli::install(), &outdir).manpage(8)?;
Bootstrap::new("hpk-info", hpk_cli::info()).manpage(outdir.as_path(), 8)?; Bootstrap::new("hpk-info", hpk_cli::info(), &outdir).manpage(8)?;
Bootstrap::new("hpk-search", hpk_cli::search()).manpage(outdir.as_path(), 8)?; Bootstrap::new("hpk-search", hpk_cli::search(), &outdir).manpage(8)?;
Bootstrap::new("hpk-remove", hpk_cli::remove()).manpage(outdir.as_path(), 8)?; Bootstrap::new("hpk-remove", hpk_cli::remove(), &outdir).manpage(8)?;
Bootstrap::new("hpk-upgrade", hpk_cli::upgrade()).manpage(outdir.as_path(), 8)?; Bootstrap::new("hpk-upgrade", hpk_cli::upgrade(), &outdir).manpage(8)?;
Ok(()) Ok(())
} }

View File

@ -26,6 +26,9 @@ fn main() -> Result<(), Box<dyn Error>> {
Some(("init", matches)) => { Some(("init", matches)) => {
let specsfile = init(matches)?; let specsfile = init(matches)?;
println!("Created specsfile {}", specsfile.display()); println!("Created specsfile {}", specsfile.display());
if matches.get_flag("edit") {
hpk_cli::edit(specsfile.to_str().unwrap())?;
}
} }
Some(("search", matches)) => search(matches)?, Some(("search", matches)) => search(matches)?,
Some(("install", matches)) => install(matches)?, Some(("install", matches)) => install(matches)?,

View File

@ -1,4 +1,24 @@
use clap::{value_parser, Arg, ArgAction, Command, ValueHint}; use clap::{value_parser, Arg, ArgAction, Command, ValueHint};
use std::{env, io, process};
/// Open the given uri in an appropriate program
pub fn edit(file: &str) -> Result<(), io::Error> {
if let Ok(ed) = env::var("EDITOR") {
run(&ed, file)
} else {
run("vi", file)
.or_else(|_| run("vim", file))
.or_else(|_| run("emacs", file))
.or_else(|_| run("nano", file))
.or_else(|_| run("ee", file))
}?;
Ok(())
}
fn run(handler: &str, arg: &str) -> Result<(), io::Error> {
process::Command::new(handler).arg(arg).status()?;
Ok(())
}
pub fn cli() -> Command { pub fn cli() -> Command {
Command::new("hpk") Command::new("hpk")
@ -94,6 +114,11 @@ pub fn init() -> Command {
.long("dependencies") .long("dependencies")
.value_delimiter(',') .value_delimiter(',')
.num_args(1..), .num_args(1..),
Arg::new("edit")
.help("open specs file in an editor")
.short('e')
.long("edit")
.action(ArgAction::SetTrue),
]) ])
} }