From 99c88b7b327a14bcc87d2a5b9a4224a67e850113 Mon Sep 17 00:00:00 2001 From: Andrew Schott Date: Tue, 25 Jun 2024 01:36:32 -0500 Subject: [PATCH] Beginnings of user input for autoupdating. --- osupdater/Cargo.lock | 48 +++++++++++++++++++++++++++++++++++++++++++ osupdater/Cargo.toml | 1 + osupdater/src/main.rs | 10 ++++++++- 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/osupdater/Cargo.lock b/osupdater/Cargo.lock index 454f0f3..f41828b 100644 --- a/osupdater/Cargo.lock +++ b/osupdater/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + [[package]] name = "color-print" version = "0.3.6" @@ -23,6 +32,15 @@ dependencies = [ "syn", ] +[[package]] +name = "input_validation" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be9a9b3bc3525ea1e1737b1f8b835c41041e73641fecc592636e1bd2d1d1c4c0" +dependencies = [ + "regex", +] + [[package]] name = "memchr" version = "2.7.2" @@ -50,6 +68,7 @@ name = "osupdater" version = "0.1.0" dependencies = [ "color-print", + "input_validation", ] [[package]] @@ -70,6 +89,35 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + [[package]] name = "syn" version = "2.0.66" diff --git a/osupdater/Cargo.toml b/osupdater/Cargo.toml index b555fb5..6dd2463 100644 --- a/osupdater/Cargo.toml +++ b/osupdater/Cargo.toml @@ -7,3 +7,4 @@ edition = "2021" [dependencies] color-print = "0.3.5" +input_validation = "0.1.2" diff --git a/osupdater/src/main.rs b/osupdater/src/main.rs index db2b984..f29fe5c 100644 --- a/osupdater/src/main.rs +++ b/osupdater/src/main.rs @@ -1,6 +1,8 @@ use std::process::{Command, Stdio}; use std::path::Path; use color_print::cprintln; +//use std::io::{stdin,stdout,Write}; +use input_validation::{get_choice}; fn trim_newline(s: &mut String) { if s.ends_with('\n') { @@ -19,6 +21,13 @@ fn main() { // Tell user that we are going to start the update procedure cprintln!("osupdater : This tool will locate and run any package/container managers on your system.\n"); cprintln!("Looking for native package managers.\n"); + + //Figure out if the program should ask if an update tool should be run + //let autoupdate_choices = vec!["Y","N"]; + //let autoupdate_index = get_choice("Shall the application autorun each update tool?", &autoupdate_choices); + //println!("Selection was {}", autoupdate_choices[autoupdate_index]); + + //Find if binaries exist and their location let find_sudo = Command::new("which") .arg("sudo").stdout(Stdio::piped()).output().unwrap(); let mut sudo_bin = String::from_utf8(find_sudo.stdout).unwrap(); @@ -160,7 +169,6 @@ fn main() { // Check container formats cprintln!("Checking application containers"); - // flatpak let path = Path::new(&flatpak_bin); if path.exists(){