aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorAndy Wortman <ixineeringeverywhere@gmail.com>2017-11-11 04:35:35 -0800
committerAndy Wortman <ixineeringeverywhere@gmail.com>2017-11-11 16:00:31 -0800
commit73dc5dda6b8ca8a8bdae0f620442e359871b0152 (patch)
tree1a3a0ff74bedf1788079ba642eb222f6a4d23c9d /src/commands
parent3601bf6433d46dea4dd1960f7a3cdc514602983d (diff)
start adding help reference
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/auth.rs7
-rw-r--r--src/commands/fav.rs6
-rw-r--r--src/commands/follow.rs6
-rw-r--r--src/commands/help.rs17
-rw-r--r--src/commands/look_up.rs6
-rw-r--r--src/commands/mod.rs20
-rw-r--r--src/commands/quit.rs4
-rw-r--r--src/commands/show_cache.rs3
-rw-r--r--src/commands/thread.rs9
-rw-r--r--src/commands/twete.rs20
-rw-r--r--src/commands/view.rs9
11 files changed, 69 insertions, 38 deletions
diff --git a/src/commands/auth.rs b/src/commands/auth.rs
index 0ed006b..0a2425d 100644
--- a/src/commands/auth.rs
+++ b/src/commands/auth.rs
@@ -14,7 +14,9 @@ static UNFAV_TWEET_URL: &str = "https://api.twitter.com/1.1/favorites/destroy.js
pub static AUTH: Command = Command {
keyword: "auth",
params: 0,
- exec: auth
+ exec: auth,
+ // TODO: support account-specific auth? profile name spec?
+ help_str: "Begin PIN-based account auth process. Second step is the `pin` command."
};
static OAUTH_REQUEST_TOKEN_URL: &str = "https://api.twitter.com/oauth/request_token";
@@ -54,7 +56,8 @@ fn auth(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
pub static PIN: Command = Command {
keyword: "pin",
params: 1,
- exec: pin
+ exec: pin,
+ help_str: "<PIN>: Complete account auth. Enter PIN from prior `auth` link to connect an account."
};
fn pin(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
diff --git a/src/commands/fav.rs b/src/commands/fav.rs
index 08ad7f0..6f769d3 100644
--- a/src/commands/fav.rs
+++ b/src/commands/fav.rs
@@ -11,7 +11,8 @@ static UNFAV_TWEET_URL: &str = "https://api.twitter.com/1.1/favorites/destroy.js
pub static UNFAV: Command = Command {
keyword: "unfav",
params: 1,
- exec: unfav
+ exec: unfav,
+ help_str: "<tweet_id>: Unfavorite a tweet."
};
fn unfav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
@@ -40,7 +41,8 @@ fn unfav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
pub static FAV: Command = Command {
keyword: "fav",
params: 1,
- exec: fav
+ exec: fav,
+ help_str: "<tweet_id>: Favorite a tweet."
};
fn fav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
diff --git a/src/commands/follow.rs b/src/commands/follow.rs
index e9099c9..3a53821 100644
--- a/src/commands/follow.rs
+++ b/src/commands/follow.rs
@@ -9,7 +9,8 @@ static UNFOLLOW_URL: &str = "https://api.twitter.com/1.1/friendships/destroy.jso
pub static UNFOLLOW: Command = Command {
keyword: "unfl",
params: 1,
- exec: unfl
+ exec: unfl,
+ help_str: "<handle>: Unfollow <handle>. No @ prefix in <handle>!"
};
fn unfl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
@@ -29,7 +30,8 @@ fn unfl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
pub static FOLLOW: Command = Command {
keyword: "fl",
params: 1,
- exec: fl
+ exec: fl,
+ help_str: "<handle>: Follow <handle>. No @ prefix in <handle>!"
};
fn fl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
diff --git a/src/commands/help.rs b/src/commands/help.rs
new file mode 100644
index 0000000..825447b
--- /dev/null
+++ b/src/commands/help.rs
@@ -0,0 +1,17 @@
+use tw;
+use ::Queryer;
+
+use tw::TweetId;
+
+use commands::Command;
+
+pub static HELP: Command = Command {
+ keyword: "help",
+ params: 0,
+ exec: help,
+ help_str: "This help prompt."
+};
+
+fn help(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
+ tweeter.state = tw::AppState::ShowHelp;
+}
diff --git a/src/commands/look_up.rs b/src/commands/look_up.rs
index dff56aa..fa83d2b 100644
--- a/src/commands/look_up.rs
+++ b/src/commands/look_up.rs
@@ -8,7 +8,8 @@ use commands::Command;
pub static LOOK_UP_USER: Command = Command {
keyword: "look_up_user",
params: 1,
- exec: look_up_user
+ exec: look_up_user,
+ help_str: "<twitter_user_id>: Look up the user by the specified twitter user ID, display name/handle."
};
fn look_up_user(line: String, tweeter: &mut tw::TwitterCache, mut queryer: &mut Queryer) {
@@ -23,7 +24,8 @@ fn look_up_user(line: String, tweeter: &mut tw::TwitterCache, mut queryer: &mut
pub static LOOK_UP_TWEET: Command = Command {
keyword: "look_up_tweet",
params: 1,
- exec: look_up_tweet
+ exec: look_up_tweet,
+ help_str: "<tweet_id>: Look up tweet by the tweet ID. If unknown, try to retrieve it."
};
// TODO: make this parse a proper tweet id
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index f7536a0..f2160f9 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -4,9 +4,11 @@ use ::Queryer;
pub struct Command {
pub keyword: &'static str,
pub params: u8,
- pub exec: fn(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer)
+ pub exec: fn(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer),
+ pub help_str: &'static str
}
+pub mod help;
pub mod auth;
pub mod show_cache;
pub mod twete;
@@ -18,6 +20,7 @@ pub mod follow;
pub mod thread;
pub static COMMANDS: &[&Command] = &[
+ &help::HELP,
&auth::AUTH,
&auth::PIN,
&show_cache::SHOW_CACHE,
@@ -39,19 +42,4 @@ pub static COMMANDS: &[&Command] = &[
&thread::FORGET_THREAD,
&thread::REMEMBER_THREAD,
&thread::LIST_THREADS
- /*
- &QUIT,
- &LOOK_UP_USER,
- &LOOK_UP_TWEET,
- &VIEW,
- &UNFAV,
- &FAV,
- &DEL,
- &TWETE,
- &QUOTE,
- &RETWETE,
- &REP,
- &THREAD
- ];
- */
];
diff --git a/src/commands/quit.rs b/src/commands/quit.rs
index 5bd8c18..dedeab6 100644
--- a/src/commands/quit.rs
+++ b/src/commands/quit.rs
@@ -8,7 +8,9 @@ use std::process::exit;
pub static QUIT: Command = Command {
keyword: "q",
params: 0,
- exec: quit
+ exec: quit,
+ // TODO: app name
+ help_str: "Gracefully exit this thing"
};
fn quit(_line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer) {
diff --git a/src/commands/show_cache.rs b/src/commands/show_cache.rs
index 59ecfc2..a57b59f 100644
--- a/src/commands/show_cache.rs
+++ b/src/commands/show_cache.rs
@@ -6,7 +6,8 @@ use commands::Command;
pub static SHOW_CACHE: Command = Command {
keyword: "show_cache",
params: 0,
- exec: show_cache
+ exec: show_cache,
+ help_str: "Dump all cached info. Probably a bad idea."
};
fn show_cache(_line: String, tweeter: &mut tw::TwitterCache, mut queryer: &mut Queryer) {
diff --git a/src/commands/thread.rs b/src/commands/thread.rs
index 6f05048..0897b21 100644
--- a/src/commands/thread.rs
+++ b/src/commands/thread.rs
@@ -9,7 +9,8 @@ use commands::Command;
pub static FORGET_THREAD: Command = Command {
keyword: "forget",
params: 1,
- exec: forget
+ exec: forget,
+ help_str: "<name>: Discard thread known by <name>. Entirely local to the client."
};
fn forget(line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer) {
@@ -20,7 +21,8 @@ fn forget(line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer)
pub static REMEMBER_THREAD: Command = Command {
keyword: "remember",
params: 2,
- exec: remember
+ exec: remember,
+ help_str: "<tweet_id> <name>: Remember the thread tipped by <tweet_id> as <name>. Entirely local to the client."
};
fn remember(line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer) {
@@ -51,7 +53,8 @@ fn remember(line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer
pub static LIST_THREADS: Command = Command {
keyword: "ls_threads",
params: 0,
- exec: ls_threads
+ exec: ls_threads,
+ help_str: "Show all known (local) threads"
};
fn ls_threads(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
diff --git a/src/commands/twete.rs b/src/commands/twete.rs
index 239e039..ff75fea 100644
--- a/src/commands/twete.rs
+++ b/src/commands/twete.rs
@@ -12,7 +12,8 @@ static CREATE_TWEET_URL: &str = "https://api.twitter.com/1.1/statuses/update.jso
pub static DEL: Command = Command {
keyword: "del",
params: 1,
- exec: del
+ exec: del,
+ help_str: "<tweet_id>: Delete tweet <tweet_id>"
};
fn del(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
@@ -41,7 +42,8 @@ fn del(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
pub static TWETE: Command = Command {
keyword: "t",
params: 0,
- exec: twete
+ exec: twete,
+ help_str: "Enter tweet compose mode."
};
fn twete(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
@@ -76,7 +78,9 @@ pub fn send_twete(text: String, tweeter: &mut tw::TwitterCache, queryer: &mut Qu
pub static THREAD: Command = Command {
keyword: "thread",
params: 2,
- exec: thread
+ exec: thread,
+ // TODO: make it actually do this..
+ help_str: "Enter compose mode, appending to a thread"
};
// the difference between threading and replying is not including
@@ -117,7 +121,9 @@ fn thread(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
pub static REP: Command = Command {
keyword: "rep",
params: 1,
- exec: rep
+ exec: rep,
+ // TODO: doc immediate reply mode
+ help_str: "<tweet_id>: Enter compose mode to reply to <tweet_id>"
};
fn rep(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
@@ -192,7 +198,8 @@ pub fn send_reply(text: String, twid: TweetId, tweeter: &mut tw::TwitterCache, q
pub static QUOTE: Command = Command {
keyword: "qt",
params: 2,
- exec: quote
+ exec: quote,
+ help_str: "<tweet_id> <text>: Quote <tweet_id> with context <text>"
};
fn quote(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
@@ -251,7 +258,8 @@ fn quote(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
pub static RETWETE: Command = Command {
keyword: "rt",
params: 1,
- exec: retwete
+ exec: retwete,
+ help_str: "<tweet_id>: Retweet <tweet_id>"
};
fn retwete(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
diff --git a/src/commands/view.rs b/src/commands/view.rs
index 0c9e974..a647391 100644
--- a/src/commands/view.rs
+++ b/src/commands/view.rs
@@ -10,7 +10,8 @@ use display;
pub static VIEW: Command = Command {
keyword: "view",
params: 1,
- exec: view
+ exec: view,
+ help_str: "<tweet_id>: Display tweet <tweet_id> with a reference URL"
};
fn view(line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer) {
@@ -34,7 +35,8 @@ fn view(line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer) {
pub static VIEW_THREAD: Command = Command {
keyword: "view_tr",
params: 1,
- exec: view_tr
+ exec: view_tr,
+ help_str: "<tweet_id>: Display whole thread leading to <tweet_id>, reference URLs for each"
};
fn view_tr(line: String, mut tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
@@ -64,7 +66,8 @@ fn view_tr(line: String, mut tweeter: &mut tw::TwitterCache, queryer: &mut Query
pub static VIEW_THREAD_FORWARD: Command = Command {
keyword: "viewthread+",
params: 1,
- exec: view_tr_forward
+ exec: view_tr_forward,
+ help_str: "help me make this work"
};
fn view_tr_forward(_line: String, _tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer) {