Remove dead code
This commit is contained in:
@@ -14,8 +14,6 @@ use spotify::Spotify;
|
|||||||
use traits::ViewExt;
|
use traits::ViewExt;
|
||||||
use ui::layout::Layout;
|
use ui::layout::Layout;
|
||||||
|
|
||||||
type CommandCb = dyn Fn(&mut Cursive, &[String]) -> Result<Option<String>, String>;
|
|
||||||
|
|
||||||
pub enum CommandResult {
|
pub enum CommandResult {
|
||||||
Consumed(Option<String>),
|
Consumed(Option<String>),
|
||||||
View(Box<dyn ViewExt>),
|
View(Box<dyn ViewExt>),
|
||||||
@@ -23,7 +21,6 @@ pub enum CommandResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct CommandManager {
|
pub struct CommandManager {
|
||||||
callbacks: HashMap<String, Option<Box<CommandCb>>>,
|
|
||||||
aliases: HashMap<String, String>,
|
aliases: HashMap<String, String>,
|
||||||
spotify: Arc<Spotify>,
|
spotify: Arc<Spotify>,
|
||||||
queue: Arc<Queue>,
|
queue: Arc<Queue>,
|
||||||
@@ -33,7 +30,6 @@ pub struct CommandManager {
|
|||||||
impl CommandManager {
|
impl CommandManager {
|
||||||
pub fn new(spotify: Arc<Spotify>, queue: Arc<Queue>, library: Arc<Library>) -> CommandManager {
|
pub fn new(spotify: Arc<Spotify>, queue: Arc<Queue>, library: Arc<Library>) -> CommandManager {
|
||||||
CommandManager {
|
CommandManager {
|
||||||
callbacks: HashMap::new(),
|
|
||||||
aliases: HashMap::new(),
|
aliases: HashMap::new(),
|
||||||
spotify,
|
spotify,
|
||||||
queue,
|
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>) {
|
pub fn register_aliases<S: Into<String>>(&mut self, name: S, aliases: Vec<S>) {
|
||||||
let name = name.into();
|
let name = name.into();
|
||||||
for a in aliases {
|
for a in aliases {
|
||||||
@@ -52,12 +44,7 @@ impl CommandManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register_all(
|
pub fn register_all(&mut self) {
|
||||||
&mut self,
|
|
||||||
spotify: Arc<Spotify>,
|
|
||||||
queue: Arc<Queue>,
|
|
||||||
library: Arc<Library>,
|
|
||||||
) {
|
|
||||||
self.register_aliases("quit", vec!["q", "x"]);
|
self.register_aliases("quit", vec!["q", "x"]);
|
||||||
self.register_aliases("playpause", vec!["pause", "toggleplay", "toggleplayback"]);
|
self.register_aliases("playpause", vec!["pause", "toggleplay", "toggleplayback"]);
|
||||||
self.register_aliases("repeat", vec!["loop"]);
|
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> {
|
fn handle_callbacks(&self, s: &mut Cursive, cmd: &Command) -> Result<Option<String>, String> {
|
||||||
let local = {
|
let local = {
|
||||||
let mut main: ViewRef<Layout> = s.find_id("main").unwrap();
|
let mut main: ViewRef<Layout> = s.find_id("main").unwrap();
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ fn main() {
|
|||||||
));
|
));
|
||||||
|
|
||||||
let mut cmd_manager = CommandManager::new(spotify.clone(), queue.clone(), library.clone());
|
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);
|
let cmd_manager = Arc::new(cmd_manager);
|
||||||
CommandManager::register_keybindings(
|
CommandManager::register_keybindings(
|
||||||
|
|||||||
Reference in New Issue
Block a user