commit 9d3c3b743246a484d4b0f049208ac4c9c3574c5a
parent 12152127b7d7ae507efd6e48a2b8438ff99d0968
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date: Tue, 3 Sep 2019 09:48:07 -0400
Add Command Line Interface
Diffstat:
2 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
@@ -6,5 +6,6 @@ edition = "2018"
[dependencies]
chrono = "0.4.8"
-toml = "0.5.3"
-dirs = "2.0"-
\ No newline at end of file
+clap = "~2.33.0"
+dirs = "2.0"
+toml = "0.5.3"+
\ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
@@ -3,6 +3,8 @@ use std::io::prelude::*;
use std::path::Path;
use std::process::Command;
+use clap::{crate_version, App, Arg, SubCommand};
+
#[derive(Debug)]
struct Config {
nick: String,
@@ -32,6 +34,43 @@ impl Config {
}
fn main() {
+ let command = App::new("twixter")
+ .version(crate_version!())
+ .about("A client for twtxt, microblog for hackers")
+ .arg(
+ Arg::with_name("config_dir")
+ .short("c")
+ .long("config")
+ .value_name("PATH")
+ .help("Specifies a custom config file location")
+ .takes_value(true),
+ )
+ .subcommand(
+ SubCommand::with_name("tweet")
+ .version(crate_version!())
+ .about("Append a new tweet to your twtxt file")
+ .arg(Arg::with_name("content").multiple(true)),
+ )
+ .subcommand(SubCommand::with_name("timeline").about("Retrieves your timeline"))
+ .subcommand(
+ SubCommand::with_name("follow")
+ .version(crate_version!())
+ .about("Adds a new source to your followings")
+ .arg(
+ Arg::with_name("nick")
+ .required(true)
+ .value_name("NICK")
+ .help("Specifies nickname to store source with"),
+ )
+ .arg(
+ Arg::with_name("url")
+ .required(true)
+ .value_name("URL")
+ .help("Specifies source url"),
+ ),
+ )
+ .get_matches();
+
// Source config.
let mut config_dir = dirs::config_dir().unwrap();
config_dir.push("twixter/config");