twixter

A twtxt command line client in Rust

git clone git://git.shimmy1996.com/twixter.git
commit 33c61e698c63ddbbdb457c246485d2dcc634fbac
parent 7a69c646583c5fe6fcd7e720ea934c608ea9101f
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date:   Wed,  4 Sep 2019 10:29:31 -0400

Use clap to parse user post content

Diffstat:
Msrc/main.rs | 17++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/main.rs b/src/main.rs
@@ -105,7 +105,22 @@ fn main() {
     fetch(&config);
 
     // Add user post.
-    let content = std::env::args().skip(1).collect::<Vec<String>>().join(" ");
+    let content = command
+        .subcommand_matches("tweet")
+        .and_then(|subcommand| {
+            subcommand.args.get("content").and_then(|matched_arg| {
+                Some(
+                    matched_arg
+                        .vals
+                        .iter()
+                        .map(|os_string| os_string.clone().into_string().unwrap())
+                        .collect::<Vec<String>>()
+                        .join(" "),
+                )
+            })
+        })
+        .unwrap_or_default();
+
     if content == "" {
         eprintln!("Error: post content must not be empty");
     } else {