aboutsummaryrefslogtreecommitdiff
path: root/src/commands/profile.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/profile.rs')
-rw-r--r--src/commands/profile.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/commands/profile.rs b/src/commands/profile.rs
new file mode 100644
index 0000000..c0d5d79
--- /dev/null
+++ b/src/commands/profile.rs
@@ -0,0 +1,38 @@
+use tw;
+use std;
+use std::collections::HashMap;
+use hyper;
+use ::Queryer;
+
+use commands::Command;
+
+pub static PROFILE: Command = Command {
+ keyword: "profile",
+ params: 1,
+ exec: switch_profile,
+ param_str: " <profile_name>",
+ help_str: "Switch to profile <profile_name>"
+};
+
+fn switch_profile(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
+ let profile_name = line.trim();
+ if tweeter.profiles.contains_key(profile_name) {
+ tweeter.curr_profile = Some(profile_name.to_owned());
+ } else {
+ tweeter.display_info.status(format!("No profile named {}", profile_name))
+ };
+}
+
+pub static PROFILES: Command = Command {
+ keyword: "profiles",
+ params: 0,
+ exec: list_profiles,
+ param_str: "",
+ help_str: "List all profiles"
+};
+
+fn list_profiles(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
+ tweeter.display_info.recv(::display::Infos::Text(
+ tweeter.profiles.keys().map(|key| key.to_owned()).collect()
+ ));
+}