This commit is contained in:
Luke Harding 2024-05-07 18:36:28 -04:00
parent 9215820374
commit c024f85f46

View File

@ -11,6 +11,8 @@
This file contains the primary logic of the application
*/
use std::env;
use colored::{ColoredString, Colorize};
use wrappers::pacman;
@ -21,7 +23,33 @@ mod wrappers;
fn main() {
println!("{}", copyright_notice());
update();
let mut args = env::args();
// Drop the file location from args
if args.next().is_none() {
error_println("Unexpected error in argument collection. Aborting.");
return;
}
let args: Vec<String> = args.collect();
for arg in &args {}
if args.is_empty() {
print_help_text();
} else {
update();
}
}
fn print_help_text() {
println!(
"rust-archlinux-updater [OPTIONS]\n\n\
Options:\n\
-h, --help | Show this help message\n\
-u | preform a regular update\n\
-p | Use paru to update the AUR packages on your system"
);
}
fn update() {
@ -64,7 +92,10 @@ fn update() {
}
fn copyright_notice() -> ColoredString {
"Rust Arch Linux Updater Copyright (C) 2024 Luke Harding <luke@lukeh990.io>\nThis program comes with ABSOLUTELY NO WARRANTY\nThis is free software, and you are welcome to redistribute it under certain conditions\n".italic()
"Rust Arch Linux Updater Copyright (C) 2024 Luke Harding <luke@lukeh990.io>\
\nThis program comes with ABSOLUTELY NO WARRANTY\
\nThis is free software, and you are welcome to redistribute it under certain conditions\n"
.italic()
}
pub fn error_println(msg: impl Into<String>) {