diff --git a/src/main.rs b/src/main.rs index 66ee701..3939bd4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 = 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 \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 \ + \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) {