feat: add installing from repositories

Signed-off-by: sisungo <[email protected]>
This commit is contained in:
2026-06-24 18:44:12 +08:00
parent b6dbfd12be
commit e2ddb7b13b
6 changed files with 305 additions and 64 deletions
+22 -4
View File
@@ -1,5 +1,10 @@
use clap::Parser;
use packie::{PackieBuilder, install::InstallOptions, package::PkgSpec};
use indicatif::ProgressBar;
use packie::{
PackieBuilder,
install::{InstallFromRepoEvent, InstallOptions},
package::PkgSpec,
};
use std::{
path::{Path, PathBuf},
str::FromStr,
@@ -32,8 +37,7 @@ pub fn main(cli: Cli) -> anyhow::Result<()> {
for i in cli.items {
match i {
Item::LocalFile(path) => {
packie::install::install_package_file(
&mut packie,
packie.install_package_file(
path,
&InstallOptions {
install_pkgspec: None,
@@ -41,7 +45,21 @@ pub fn main(cli: Cli) -> anyhow::Result<()> {
)?;
}
Item::PkgSpec(pkgspec) => {
todo!()
let progress = ProgressBar::new(0);
packie
.install_from_repo(pkgspec)
.on_event(|ev| match ev {
InstallFromRepoEvent::Download(ev, sum, total) => {
progress.set_length(total);
progress.set_position(sum);
}
InstallFromRepoEvent::Install(pkg, sum, total) => {
progress.set_prefix(pkg);
progress.set_length(total);
progress.set_position(sum);
}
})
.run()?;
}
}
}