Added help()

This commit is contained in:
Beefki 2017-10-14 09:20:47 -05:00
parent 9d9707d5d7
commit d87d36af3f
3 changed files with 30 additions and 19 deletions

View File

@ -23,13 +23,6 @@ impl Config {
Management::CompleteClear => (pac.complete_cache_clear.0, pac.complete_cache_clear.1), Management::CompleteClear => (pac.complete_cache_clear.0, pac.complete_cache_clear.1),
}; };
/*
let term = match self.term {
None => "",
Some(ref val) => val,
};
*/
match (&prog.1, &self.term) { match (&prog.1, &self.term) {
(&None, &None) => { (&None, &None) => {
Command::new(&prog.0).spawn().expect( Command::new(&prog.0).spawn().expect(
@ -52,17 +45,6 @@ impl Config {
std::process::exit(1) std::process::exit(1)
} }
} }
/*
if prog.1.is_none() && self.term.is_none() {
}else{
Command::new(&prog.0)
.arg(&prog.1)
.arg(term)
.spawn()
.expect("Failed to call package manager")
}
*/
} }
/// Creates a `Config` from passed arguments, parses the `Management` enum /// Creates a `Config` from passed arguments, parses the `Management` enum
/// and term (if any). Requires an action, while the term can be `None`. /// and term (if any). Requires an action, while the term can be `None`.
@ -70,6 +52,7 @@ impl Config {
let action = match Management::parse(std::env::args().nth(1)) { let action = match Management::parse(std::env::args().nth(1)) {
None => { None => {
println!("No command actions passed"); println!("No command actions passed");
help();
std::process::exit(0) std::process::exit(0)
} }
Some(command) => command, Some(command) => command,

View File

@ -74,3 +74,18 @@ fn main() {
std::process::exit(0); std::process::exit(0);
} }
} }
fn help() {
println!(
"COMMANDS:
-S Installs a new package
-Ss Searches for a package
-Sy Updates local cache from repo
-Su Upgrades with just your local cache
-Syu Upgrades the local cache and then updates the system
-R Removes a package from the system
-Rdns Purges a package from the system
-Sc Clears your local cache
-Scc Purges your local cache"
);
}

View File

@ -1,3 +1,5 @@
use super::*;
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Debug)] #[derive(Debug)]
/// enum for passing data around the program. Contains each option /// enum for passing data around the program. Contains each option
@ -19,7 +21,14 @@ impl Management {
/// Setup here to use the same commands `pacman` does though it's no /// Setup here to use the same commands `pacman` does though it's no
/// where near as robust. This is very basic and may be improved later /// where near as robust. This is very basic and may be improved later
pub fn parse(man: Option<String>) -> Option<Management> { pub fn parse(man: Option<String>) -> Option<Management> {
match &*man.expect("No commands were passed") { let man = match man {
None => {
help();
std::process::exit(0);
}
Some(val) => val,
};
match &*man {
"-Ss" => Some(Management::Search), "-Ss" => Some(Management::Search),
"-S" => Some(Management::Install), "-S" => Some(Management::Install),
"-R" => Some(Management::Uninstall), "-R" => Some(Management::Uninstall),
@ -29,6 +38,10 @@ impl Management {
"-Syu" => Some(Management::Full), "-Syu" => Some(Management::Full),
"-Sc" => Some(Management::Clear), "-Sc" => Some(Management::Clear),
"-Scc" => Some(Management::CompleteClear), "-Scc" => Some(Management::CompleteClear),
"-h" | "--help" | "help" => {
help();
std::process::exit(0)
}
_ => None, _ => None,
} }