add showing group content (WIP)

This commit is contained in:
steven-omaha
2023-01-10 18:50:17 +01:00
parent d4c97679e2
commit 42d318298c
3 changed files with 16 additions and 0 deletions
+1
View File
@@ -1,6 +1,7 @@
pub(crate) const CLEAN: &str = "clean"; pub(crate) const CLEAN: &str = "clean";
pub(crate) const EDIT: &str = "edit"; pub(crate) const EDIT: &str = "edit";
pub(crate) const GROUPS: &str = "groups"; pub(crate) const GROUPS: &str = "groups";
pub(crate) const SHOW: &str = "show";
pub(crate) const SYNC: &str = "sync"; pub(crate) const SYNC: &str = "sync";
pub(crate) const UNMANAGED: &str = "unmanaged"; pub(crate) const UNMANAGED: &str = "unmanaged";
pub(crate) const VERSION: &str = "version"; pub(crate) const VERSION: &str = "version";
+6
View File
@@ -16,6 +16,12 @@ fn get_arg_parser() -> Command<'static> {
.arg(Arg::new("group").multiple_values(true)), .arg(Arg::new("group").multiple_values(true)),
) )
.subcommand(Command::new(GROUPS).about("show names of imported groups")) .subcommand(Command::new(GROUPS).about("show names of imported groups"))
.subcommand(
Command::new(SHOW)
.about("show packages under an imported group")
.arg_required_else_help(true)
.arg(Arg::new("group").multiple_values(true)),
)
.subcommand(Command::new(SYNC).about("install packages from all imported groups")) .subcommand(Command::new(SYNC).about("install packages from all imported groups"))
.subcommand( .subcommand(
Command::new(UNMANAGED) Command::new(UNMANAGED)
+9
View File
@@ -29,6 +29,7 @@ impl Pacdef {
self.edit_group_files(groups).context("editing group files") self.edit_group_files(groups).context("editing group files")
} }
Some((action::GROUPS, _)) => Ok(self.show_groups()), Some((action::GROUPS, _)) => Ok(self.show_groups()),
Some((action::SHOW, _)) => Ok(self.show_packages_under_group()),
Some((action::SYNC, _)) => Ok(self.install_packages()), Some((action::SYNC, _)) => Ok(self.install_packages()),
Some((action::UNMANAGED, _)) => Ok(self.show_unmanaged_packages()), Some((action::UNMANAGED, _)) => Ok(self.show_unmanaged_packages()),
Some((action::VERSION, _)) => Ok(self.show_version()), Some((action::VERSION, _)) => Ok(self.show_version()),
@@ -167,6 +168,14 @@ impl Pacdef {
backend.remove_packages(packages); backend.remove_packages(packages);
} }
} }
fn show_packages_under_group(&self) {
let groups = self.args.get_many::<String>("group").unwrap();
for arg_group in groups {
let group = self.groups.iter().find(|g| g.name == *arg_group).unwrap();
println!("{group}");
}
}
} }
fn show_error(error: anyhow::Error, backend: Box<dyn Backend>) { fn show_error(error: anyhow::Error, backend: Box<dyn Backend>) {