Added help()
This commit is contained in:
parent
9d9707d5d7
commit
d87d36af3f
@ -23,13 +23,6 @@ impl Config {
|
||||
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) {
|
||||
(&None, &None) => {
|
||||
Command::new(&prog.0).spawn().expect(
|
||||
@ -52,17 +45,6 @@ impl Config {
|
||||
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
|
||||
/// 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)) {
|
||||
None => {
|
||||
println!("No command actions passed");
|
||||
help();
|
||||
std::process::exit(0)
|
||||
}
|
||||
Some(command) => command,
|
||||
|
15
src/main.rs
15
src/main.rs
@ -74,3 +74,18 @@ fn main() {
|
||||
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"
|
||||
);
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
use super::*;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
/// 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
|
||||
/// where near as robust. This is very basic and may be improved later
|
||||
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),
|
||||
"-S" => Some(Management::Install),
|
||||
"-R" => Some(Management::Uninstall),
|
||||
@ -29,6 +38,10 @@ impl Management {
|
||||
"-Syu" => Some(Management::Full),
|
||||
"-Sc" => Some(Management::Clear),
|
||||
"-Scc" => Some(Management::CompleteClear),
|
||||
"-h" | "--help" | "help" => {
|
||||
help();
|
||||
std::process::exit(0)
|
||||
}
|
||||
_ => None,
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user