summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2022-11-09 12:50:44 -0500
committerTyler Murphy <tylermurphy534@gmail.com>2022-11-09 12:50:44 -0500
commit49c1c8e4245e5cf93903d5a84b70dc11232b69af (patch)
tree9876afedeb9692a4accc6e165f1aa4b4736a5b47 /src/main.rs
parentupdate readme (diff)
downloadcrab-49c1c8e4245e5cf93903d5a84b70dc11232b69af.tar.gz
crab-49c1c8e4245e5cf93903d5a84b70dc11232b69af.tar.bz2
crab-49c1c8e4245e5cf93903d5a84b70dc11232b69af.zip
force valid arguments
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 5fab1d9..7c3829f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5,7 +5,7 @@ use nix::unistd;
extern crate time;
-// const ERROR_COMMAND: u8 = 1;
+const ERROR_ARGS: u8 = 1;
const ERROR_CONFIG: u8 = 2;
const ERROR_NO_USER: u8 = 3;
const ERROR_NOT_AUTHORIZED: u8 = 4;
@@ -18,7 +18,13 @@ mod help;
fn main() -> ExitCode {
let args: Vec<String> = env::args().collect();
- let flags = flags::parse(&args[1..]);
+ let flags = match flags::parse(&args[1..]) {
+ Some(data) => data,
+ None => {
+ help::help();
+ return ExitCode::from(ERROR_ARGS);
+ }
+ };
if flags.version {
println!("crab version 0.0.3");
return ExitCode::SUCCESS;
@@ -132,4 +138,4 @@ fn config(path: &str) -> Option<Config> {
users.push((user, persist));
}
Some(Config{users})
-} \ No newline at end of file
+}