implement editing of files
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ fn get_arg_parser() -> Command<'static> {
|
||||
Command::new(EDIT)
|
||||
.about("edit one or more existing group files")
|
||||
.arg_required_else_help(true)
|
||||
.arg(Arg::new("group")),
|
||||
.arg(Arg::new("group").multiple_values(true)),
|
||||
)
|
||||
.subcommand(Command::new(GROUPS).about("show names of imported groups"))
|
||||
.subcommand(Command::new(SYNC).about("install packages from all imported groups"))
|
||||
|
||||
+2
-4
@@ -1,15 +1,14 @@
|
||||
use std::os::unix::process::CommandExt;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
use crate::Package;
|
||||
|
||||
pub fn run_edit_command(files: &[&Path]) {
|
||||
pub fn run_edit_command(files: &[PathBuf]) {
|
||||
let mut cmd = Command::new("nvim");
|
||||
for f in files {
|
||||
cmd.arg(f.to_string_lossy().to_string());
|
||||
}
|
||||
dbg!(&cmd);
|
||||
cmd.exec();
|
||||
}
|
||||
|
||||
@@ -19,6 +18,5 @@ pub fn run_install_command(diff: Vec<Package>) {
|
||||
for p in diff {
|
||||
cmd.arg(format!("{p}"));
|
||||
}
|
||||
dbg!(&cmd);
|
||||
cmd.exec();
|
||||
}
|
||||
|
||||
+2
-5
@@ -2,7 +2,7 @@ use std::collections::HashSet;
|
||||
use std::process::exit;
|
||||
|
||||
use crate::action;
|
||||
use crate::cmd::run_install_command;
|
||||
use crate::cmd::{run_edit_command, run_install_command};
|
||||
use crate::db::{get_all_installed_packages, get_explicitly_installed_packages};
|
||||
use crate::Group;
|
||||
use crate::Package;
|
||||
@@ -62,7 +62,6 @@ impl Pacdef {
|
||||
|
||||
pub fn run_action_from_arg(self) {
|
||||
match self.args.subcommand() {
|
||||
// Some((args::EDIT, groups)) => println!("{groups:#?}"),
|
||||
Some((action::EDIT, groups)) => self.edit_group_files(groups),
|
||||
Some((action::GROUPS, _)) => self.show_groups(),
|
||||
Some((action::SYNC, _)) => self.install_packages(),
|
||||
@@ -82,9 +81,7 @@ impl Pacdef {
|
||||
buf
|
||||
})
|
||||
.collect();
|
||||
for f in files {
|
||||
println!("{f:#?}");
|
||||
}
|
||||
run_edit_command(&files)
|
||||
}
|
||||
|
||||
pub(crate) fn show_version(self) {
|
||||
|
||||
Reference in New Issue
Block a user