add ui module
This commit is contained in:
Generated
+7
@@ -21,6 +21,12 @@ dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.66"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
@@ -357,6 +363,7 @@ name = "pacdef"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"alpm",
|
||||
"anyhow",
|
||||
"clap 3.2.20",
|
||||
"criterion",
|
||||
]
|
||||
|
||||
@@ -7,6 +7,7 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
alpm = "2.2.1"
|
||||
anyhow = "1.0.66"
|
||||
clap = "3.2.20"
|
||||
|
||||
[profile.release]
|
||||
|
||||
@@ -2,6 +2,7 @@ pub mod args;
|
||||
pub mod db;
|
||||
pub mod group;
|
||||
pub mod package;
|
||||
pub mod ui;
|
||||
|
||||
pub use group::Group;
|
||||
pub use package::Package;
|
||||
|
||||
+4
-13
@@ -1,10 +1,9 @@
|
||||
use std::io::BufRead;
|
||||
use std::io::Write;
|
||||
use std::os::unix::process::CommandExt;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::exit;
|
||||
use std::{collections::HashSet, process::Command};
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::ArgMatches;
|
||||
|
||||
use pacdef::args;
|
||||
@@ -13,20 +12,12 @@ use pacdef::group::GROUPS_DIR;
|
||||
use pacdef::Group;
|
||||
use pacdef::Package;
|
||||
|
||||
fn main() {
|
||||
fn main() -> Result<()> {
|
||||
let args = args::get_matched_arguments();
|
||||
let groups = Group::load_from_dir();
|
||||
let pacdef = Pacdef::new(args, groups);
|
||||
pacdef.run_action_from_arg();
|
||||
}
|
||||
|
||||
fn get_user_confirmation() {
|
||||
print!("Continue? [Y/n] ");
|
||||
std::io::stdout().flush().unwrap();
|
||||
let reply = std::io::stdin().lock().lines().next().unwrap().unwrap();
|
||||
if !(reply.is_empty() || reply.to_lowercase().contains('y')) {
|
||||
exit(0)
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_edit_command(files: &[&Path]) {
|
||||
@@ -94,7 +85,7 @@ impl Pacdef {
|
||||
println!(" {p}");
|
||||
}
|
||||
println!();
|
||||
get_user_confirmation();
|
||||
pacdef::ui::get_user_confirmation();
|
||||
|
||||
run_install_command(diff);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
use std::process::exit;
|
||||
|
||||
use std::io::Write::std::io;
|
||||
|
||||
use std;
|
||||
|
||||
pub(crate) fn get_user_confirmation() {
|
||||
print!("Continue? [Y/n] ");
|
||||
std::io::stdout().flush().unwrap();
|
||||
let reply = std::io::stdin().lock().lines().next().unwrap().unwrap();
|
||||
if !(reply.is_empty() || reply.to_lowercase().contains('y')) {
|
||||
exit(0)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user