From d1a33a3a167d47541561ca9597d2d5f28431605f Mon Sep 17 00:00:00 2001 From: Andy Wortman Date: Sat, 11 Nov 2017 16:51:39 -0800 Subject: add a little more help info, describe tweets/compose mode/commands --- src/commands/auth.rs | 4 +++- src/commands/fav.rs | 6 ++++-- src/commands/follow.rs | 6 ++++-- src/commands/help.rs | 1 + src/commands/look_up.rs | 6 ++++-- src/commands/mod.rs | 1 + src/commands/quit.rs | 1 + src/commands/show_cache.rs | 1 + src/commands/thread.rs | 7 +++++-- src/commands/twete.rs | 14 ++++++++++---- src/commands/view.rs | 7 +++++-- src/main.rs | 22 ++++++++++++++++++++-- 12 files changed, 59 insertions(+), 17 deletions(-) diff --git a/src/commands/auth.rs b/src/commands/auth.rs index 0a2425d..7d01451 100644 --- a/src/commands/auth.rs +++ b/src/commands/auth.rs @@ -15,6 +15,7 @@ pub static AUTH: Command = Command { keyword: "auth", params: 0, exec: auth, + param_str: "", // TODO: support account-specific auth? profile name spec? help_str: "Begin PIN-based account auth process. Second step is the `pin` command." }; @@ -57,7 +58,8 @@ pub static PIN: Command = Command { keyword: "pin", params: 1, exec: pin, - help_str: ": Complete account auth. Enter PIN from prior `auth` link to connect an account." + param_str: " ", + help_str: "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 6f769d3..7a4852e 100644 --- a/src/commands/fav.rs +++ b/src/commands/fav.rs @@ -12,7 +12,8 @@ pub static UNFAV: Command = Command { keyword: "unfav", params: 1, exec: unfav, - help_str: ": Unfavorite a tweet." + param_str: " ", + help_str: "Unfavorite a tweet." }; fn unfav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { @@ -42,7 +43,8 @@ pub static FAV: Command = Command { keyword: "fav", params: 1, exec: fav, - help_str: ": Favorite a tweet." + param_str: "", + help_str: "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 3a53821..3a29252 100644 --- a/src/commands/follow.rs +++ b/src/commands/follow.rs @@ -10,7 +10,8 @@ pub static UNFOLLOW: Command = Command { keyword: "unfl", params: 1, exec: unfl, - help_str: ": Unfollow . No @ prefix in !" + param_str: " ", + help_str: "Unfollow . No @ prefix in !" }; fn unfl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { @@ -31,7 +32,8 @@ pub static FOLLOW: Command = Command { keyword: "fl", params: 1, exec: fl, - help_str: ": Follow . No @ prefix in !" + param_str: " ", + help_str: "Follow . No @ prefix in !" }; fn fl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { diff --git a/src/commands/help.rs b/src/commands/help.rs index 825447b..c99681e 100644 --- a/src/commands/help.rs +++ b/src/commands/help.rs @@ -9,6 +9,7 @@ pub static HELP: Command = Command { keyword: "help", params: 0, exec: help, + param_str: "", help_str: "This help prompt." }; diff --git a/src/commands/look_up.rs b/src/commands/look_up.rs index fa83d2b..7bd5885 100644 --- a/src/commands/look_up.rs +++ b/src/commands/look_up.rs @@ -9,7 +9,8 @@ pub static LOOK_UP_USER: Command = Command { keyword: "look_up_user", params: 1, exec: look_up_user, - help_str: ": Look up the user by the specified twitter user ID, display name/handle." + param_str: " ", + help_str: "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) { @@ -25,7 +26,8 @@ pub static LOOK_UP_TWEET: Command = Command { keyword: "look_up_tweet", params: 1, exec: look_up_tweet, - help_str: ": Look up tweet by the tweet ID. If unknown, try to retrieve it." + param_str: " ", + help_str: "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 f2160f9..e8efdb1 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -5,6 +5,7 @@ pub struct Command { pub keyword: &'static str, pub params: u8, pub exec: fn(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer), + pub param_str: &'static str, pub help_str: &'static str } diff --git a/src/commands/quit.rs b/src/commands/quit.rs index dedeab6..6638299 100644 --- a/src/commands/quit.rs +++ b/src/commands/quit.rs @@ -9,6 +9,7 @@ pub static QUIT: Command = Command { keyword: "q", params: 0, exec: quit, + param_str: "", // TODO: app name help_str: "Gracefully exit this thing" }; diff --git a/src/commands/show_cache.rs b/src/commands/show_cache.rs index a57b59f..fffcdb6 100644 --- a/src/commands/show_cache.rs +++ b/src/commands/show_cache.rs @@ -7,6 +7,7 @@ pub static SHOW_CACHE: Command = Command { keyword: "show_cache", params: 0, exec: show_cache, + param_str: "", help_str: "Dump all cached info. Probably a bad idea." }; diff --git a/src/commands/thread.rs b/src/commands/thread.rs index 0897b21..71d0e52 100644 --- a/src/commands/thread.rs +++ b/src/commands/thread.rs @@ -10,7 +10,8 @@ pub static FORGET_THREAD: Command = Command { keyword: "forget", params: 1, exec: forget, - help_str: ": Discard thread known by . Entirely local to the client." + param_str: " ", + help_str: "Discard thread known by . Entirely local to the client." }; fn forget(line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer) { @@ -22,7 +23,8 @@ pub static REMEMBER_THREAD: Command = Command { keyword: "remember", params: 2, exec: remember, - help_str: " : Remember the thread tipped by as . Entirely local to the client." + param_str: " ", + help_str: "Remember the thread tipped by as . Entirely local to the client." }; fn remember(line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer) { @@ -54,6 +56,7 @@ pub static LIST_THREADS: Command = Command { keyword: "ls_threads", params: 0, exec: ls_threads, + param_str: "", help_str: "Show all known (local) threads" }; diff --git a/src/commands/twete.rs b/src/commands/twete.rs index ff75fea..dbea81b 100644 --- a/src/commands/twete.rs +++ b/src/commands/twete.rs @@ -13,7 +13,8 @@ pub static DEL: Command = Command { keyword: "del", params: 1, exec: del, - help_str: ": Delete tweet " + param_str: " ", + help_str: "Delete tweet " }; fn del(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { @@ -43,6 +44,7 @@ pub static TWETE: Command = Command { keyword: "t", params: 0, exec: twete, + param_str: "", help_str: "Enter tweet compose mode." }; @@ -79,6 +81,7 @@ pub static THREAD: Command = Command { keyword: "thread", params: 2, exec: thread, + param_str: " ", // should be optional.. // TODO: make it actually do this.. help_str: "Enter compose mode, appending to a thread" }; @@ -122,8 +125,9 @@ pub static REP: Command = Command { keyword: "rep", params: 1, exec: rep, + param_str: " ", // TODO: doc immediate reply mode - help_str: ": Enter compose mode to reply to " + help_str: "Enter compose mode to reply to " }; fn rep(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { @@ -199,7 +203,8 @@ pub static QUOTE: Command = Command { keyword: "qt", params: 2, exec: quote, - help_str: " : Quote with context " + param_str: " ", + help_str: "Quote with context " }; fn quote(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { @@ -259,7 +264,8 @@ pub static RETWETE: Command = Command { keyword: "rt", params: 1, exec: retwete, - help_str: ": Retweet " + param_str: " ", + help_str: "Retweet " }; fn retwete(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { diff --git a/src/commands/view.rs b/src/commands/view.rs index a647391..15c94b1 100644 --- a/src/commands/view.rs +++ b/src/commands/view.rs @@ -11,7 +11,8 @@ pub static VIEW: Command = Command { keyword: "view", params: 1, exec: view, - help_str: ": Display tweet with a reference URL" + param_str: " ", + help_str: "Display tweet with a reference URL" }; fn view(line: String, tweeter: &mut tw::TwitterCache, _queryer: &mut Queryer) { @@ -36,7 +37,8 @@ pub static VIEW_THREAD: Command = Command { keyword: "view_tr", params: 1, exec: view_tr, - help_str: ": Display whole thread leading to , reference URLs for each" + param_str: " ", + help_str: "Display whole thread leading to , reference URLs for each" }; fn view_tr(line: String, mut tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { @@ -67,6 +69,7 @@ pub static VIEW_THREAD_FORWARD: Command = Command { keyword: "viewthread+", params: 1, exec: view_tr_forward, + param_str: "", help_str: "help me make this work" }; diff --git a/src/main.rs b/src/main.rs index f2842c4..031ad37 100644 --- a/src/main.rs +++ b/src/main.rs @@ -381,9 +381,27 @@ fn do_ui(ui_rx_orig: chan::Receiver { - let mut help_lines = vec![]; + let mut help_lines: Vec = vec![ + " Tweets", + " ", + "Tweets are identified in four (really, three) ways:", + " twitter:1235 - there's no local copy for it, when you look it up I'll have to ask Twitter for it.", + // TODO: + " YYYYMMDD:NNNN - NNNN'th tweet on YYYYMMDD. Numbered as I got them, not by date tweet was made. For example, 20170803:NNNN. NOTE: not currently well supported. Don't even try to use.", + " :NNNN - NNNN'th tweet since the first I saw.", + // TODO: + " NNNN - NNNN'th tweet of today. Again, numbered by the order I saw it. NOTE: currently this isn't well supported. Use the :ID format above with the same number for now", + " (ex: you want to reply to a tweet `id 1234`, do `rep :1234`, with :, rather than without)", + " ", + "Tweets can be made immediately by providing the text as part of a command,", + " (like `t hello, world!`)", + "or in \"compose mode\" with relevant context shown. If you end up in compose mode and want to get back to a normal prompt, press escape.", + " ", + " Commands", + " " + ].into_iter().map(|x| x.to_owned()).collect(); for command in commands::COMMANDS { - help_lines.push(format!("{} {}", command.keyword, command.help_str)); + help_lines.push(format!("{}{: