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, version 3 of the License ONLY.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import std
.path
: absolutePath
;
27 void main (string
[] args
) {
28 if (args
.length
< 2) {
30 "usage: ampercli command [args]\n",
42 //amperRPCall!amperScanDir("/home/www/dox/muzax/irij/flac/2006_rusalka");
43 // hack! convert anything that looks like a file to a full path
44 foreach (ref string s
; args
[1..$]) {
45 import std
.file
: exists
;
47 if (s
.exists
) s
= absolutePath(s
);
48 } catch (Exception e
) {}
51 for (usize aidx
= 1; aidx
< args
.length
; ) {
52 string cmd
= args
[aidx
++];
55 if (aidx
>= args
.length
) assert(0, "no argument for command '"~cmd
~"'");
56 amperRPCall
!amperScanDir(absolutePath(args
[aidx
++]), true);
59 if (aidx
>= args
.length
) assert(0, "no argument for command '"~cmd
~"'");
60 amperRPCall
!amperScanDir(absolutePath(args
[aidx
++]), false);
62 case "play": amperRPCall
!amperPlay(); break;
63 case "stop": amperRPCall
!amperStop(); break;
64 case "pause": amperRPCall
!amperTogglePause(); break;
65 case "clear": amperRPCall
!amperClearPlaylist(); break;
66 case "title": writeln(amperRPCall
!amperGetSongVisTitle()); break;
68 if (cmd
.length
&& cmd
[0] == '+') {
69 string command
= cmd
[1..$];
70 while (aidx
< args
.length
) {
71 string s
= args
[aidx
++];
72 if (s
.length
== 0) continue;
73 if (command
.length
&& command
[$-1] > ' ') command
~= ' ';
76 amperRPCall
!amperConsoleCommand(command
);
81 amperRPCall
!amperClearPlaylist();
83 while (aidx
< args
.length
) amperRPCall
!amperScanDir(absolutePath(args
[aidx
++]), true);
84 amperRPCall
!amperPlay();
87 assert(0, "invalid command: '"~cmd
~"'");