1 /* coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
2 * Understanding is not required. Only obedience.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 import std
.path
: absolutePath
;
28 void main (string
[] args
) {
29 if (args
.length
< 2) {
31 "usage: ampercli command [args]\n",
43 //amperRPCall!amperScanDir("/home/www/dox/muzax/irij/flac/2006_rusalka");
44 // hack! convert anything that looks like a file to a full path
45 foreach (ref string s
; args
[1..$]) {
46 import std
.file
: exists
;
48 if (s
.exists
) s
= absolutePath(s
);
49 } catch (Exception e
) {}
52 for (usize aidx
= 1; aidx
< args
.length
; ) {
53 string cmd
= args
[aidx
++];
56 if (aidx
>= args
.length
) assert(0, "no argument for command '"~cmd
~"'");
57 amperRPCall
!amperScanDir(absolutePath(args
[aidx
++]), true);
60 if (aidx
>= args
.length
) assert(0, "no argument for command '"~cmd
~"'");
61 amperRPCall
!amperScanDir(absolutePath(args
[aidx
++]), false);
63 case "play": amperRPCall
!amperPlay(); break;
64 case "stop": amperRPCall
!amperStop(); break;
65 case "pause": amperRPCall
!amperTogglePause(); break;
66 case "clear": amperRPCall
!amperClearPlaylist(); break;
67 case "title": writeln(amperRPCall
!amperGetSongVisTitle()); break;
69 if (cmd
.length
&& cmd
[0] == '+') {
70 string command
= cmd
[1..$];
71 while (aidx
< args
.length
) {
72 string s
= args
[aidx
++];
73 if (s
.length
== 0) continue;
74 if (command
.length
&& command
[$-1] > ' ') command
~= ' ';
77 amperRPCall
!amperConsoleCommand(command
);
82 amperRPCall
!amperClearPlaylist();
84 while (aidx
< args
.length
) amperRPCall
!amperScanDir(absolutePath(args
[aidx
++]), true);
85 amperRPCall
!amperPlay();
88 assert(0, "invalid command: '"~cmd
~"'");