12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/quiyo/core.rb', line 12
def showprompt
Readline.completion_append_character = " "
Readline.completion_proc = Proc.new { |str|
Dir[PATH+str+'*'].grep( /^#{Regexp.escape(str)}/ )
}
while line = self.readline_hist
@mpd.connect unless @mpd.connected?
action = line.split
actions = {
"np" => lambda { nowplaying() },
"info" => lambda { info },
"play" => lambda { play(action[1]) },
"pause" => lambda { pause },
"stop" => lambda { stop },
"next" => lambda { playnext },
"previous" => lambda { playprevious },
"lsplaylist" => lambda { lsplist },
"clearplaylist" => lambda { clearplist },
"addtoplaylist" => lambda { addtoplist(action) },
"delfromplaylist" => lambda { removefromplist(action[1]) },
"search" => lambda { search(action) },
"list-artists" => lambda { list("artists") },
"list-albums" => lambda { list("albums", action) },
"love" => lambda { love },
"loved" => lambda { loved },
"volume" => lambda { vol(action[1]) },
"quit" => lambda { quit },
"verbose" => lambda { eval(action.drop(1).join(" ")) }
}
CONF["aliases"].each { |k,v| actions[k] = lambda { eval(v) } }
actions[action[0]].call
end
end
|