diff options
author | Ben Morrison <ben@gbmor.dev> | 2020-05-26 23:47:52 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2020-05-26 23:54:20 -0400 |
commit | 99c5537622344ecba5a4c7d23a9bc227d9bd7fe3 (patch) | |
tree | e5d75ac91f75ebdef6e076825fbfe23e8fb1557c /src/main.rs | |
parent | 896f987f2705d1c5152d6c0741c377e3612f048a (diff) | |
download | clinte-99c5537622344ecba5a4c7d23a9bc227d9bd7fe3.tar.gz |
post ID can be specified as an argument. if absent, user will be prompted
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs index 06fb4ca..f6d136d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,12 +30,9 @@ fn main() { if arg_matches.subcommand_matches("post").is_some() { log::info!("New post..."); error::helper(posts::create(&db), "Error creating new post"); - } else if arg_matches.subcommand_matches("update").is_some() { - let id: u32 = if let Some(val) = arg_matches.subcommand_matches("update_handler") { - error::helper( - val.value_of("id").unwrap_or_else(|| "0").parse(), - "Couldn't parse ID", - ) + } else if let Some(updmatch) = arg_matches.subcommand_matches("update") { + let id: u32 = if let Some(val) = updmatch.value_of("id") { + error::helper(val.parse(), "Couldn't parse ID") } else { 0 }; @@ -46,12 +43,9 @@ fn main() { posts::update_handler(&db, id), format!("Error updating post {}", id).as_ref(), ); - } else if arg_matches.subcommand_matches("delete").is_some() { - let id: u32 = if let Some(val) = arg_matches.subcommand_matches("update_handler") { - error::helper( - val.value_of("id").unwrap_or_else(|| "0").parse(), - "Couldn't parse ID", - ) + } else if let Some(delmatch) = arg_matches.subcommand_matches("delete") { + let id: u32 = if let Some(val) = delmatch.value_of("id") { + error::helper(val.parse(), "Couldn't parse ID") } else { 0 }; |