Remove dead code

This commit is contained in:
Rasmus Larsen
2019-05-21 16:34:50 +02:00
parent 4343343ee7
commit 5500b34887
2 changed files with 2 additions and 23 deletions

View File

@@ -14,8 +14,6 @@ use spotify::Spotify;
use traits::ViewExt;
use ui::layout::Layout;
type CommandCb = dyn Fn(&mut Cursive, &[String]) -> Result<Option<String>, String>;
pub enum CommandResult {
Consumed(Option<String>),
View(Box<dyn ViewExt>),
@@ -23,7 +21,6 @@ pub enum CommandResult {
}
pub struct CommandManager {
callbacks: HashMap<String, Option<Box<CommandCb>>>,
aliases: HashMap<String, String>,
spotify: Arc<Spotify>,
queue: Arc<Queue>,
@@ -33,7 +30,6 @@ pub struct CommandManager {
impl CommandManager {
pub fn new(spotify: Arc<Spotify>, queue: Arc<Queue>, library: Arc<Library>) -> CommandManager {
CommandManager {
callbacks: HashMap::new(),
aliases: HashMap::new(),
spotify,
queue,
@@ -41,10 +37,6 @@ impl CommandManager {
}
}
pub fn register_command<S: Into<String>>(&mut self, name: S, cb: Option<Box<CommandCb>>) {
self.callbacks.insert(name.into(), cb);
}
pub fn register_aliases<S: Into<String>>(&mut self, name: S, aliases: Vec<S>) {
let name = name.into();
for a in aliases {
@@ -52,12 +44,7 @@ impl CommandManager {
}
}
pub fn register_all(
&mut self,
spotify: Arc<Spotify>,
queue: Arc<Queue>,
library: Arc<Library>,
) {
pub fn register_all(&mut self) {
self.register_aliases("quit", vec!["q", "x"]);
self.register_aliases("playpause", vec!["pause", "toggleplay", "toggleplayback"]);
self.register_aliases("repeat", vec!["loop"]);
@@ -139,14 +126,6 @@ impl CommandManager {
}
}
fn handle_aliases(&self, name: &str) -> String {
if let Some(s) = self.aliases.get(name) {
self.handle_aliases(s)
} else {
name.to_string()
}
}
fn handle_callbacks(&self, s: &mut Cursive, cmd: &Command) -> Result<Option<String>, String> {
let local = {
let mut main: ViewRef<Layout> = s.find_id("main").unwrap();

View File

@@ -185,7 +185,7 @@ fn main() {
));
let mut cmd_manager = CommandManager::new(spotify.clone(), queue.clone(), library.clone());
cmd_manager.register_all(spotify.clone(), queue.clone(), library.clone());
cmd_manager.register_all();
let cmd_manager = Arc::new(cmd_manager);
CommandManager::register_keybindings(