2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 module gaem
.utils
.cliarg
is aliced
;
21 import gaem
.utils
.loader
;
25 // ////////////////////////////////////////////////////////////////////////// //
26 NodeFunc
[] cliProcessArgs(Opts
...) (ref string
[] args
, void delegate (Gmk gmk
) procgmk
=null) {
30 bool doScripts
= true;
31 bool doActions
= true;
32 bool dumpFileNames
= false;
33 foreach (string fname
; args
[1..$]) {
39 if (fname
.length
== 0) continue;
40 if (fname
== "--") { nomore
= true; continue; }
41 if (fname
== "-S") { doScripts
= false; continue; }
42 if (fname
== "-A") { doActions
= false; continue; }
43 if (fname
== "-d") { dumpFileNames
= true; continue; }
45 foreach (immutable idx
, immutable val
; Opts
) {
46 static if (idx
%2 == 0) {
47 if (fname
== Opts
[idx
]) { found
= true; Opts
[idx
+1](fname
); break; }
51 if (fname
[0] == '-') throw new Exception("invalid option: '"~fname
~"'");
52 if (fname
[0] == '@') {
53 if (fname
.length
< 2) assert(0, "gmk file?");
54 if (dumpFileNames
) { import std
.stdio
; writeln("loading '", fname
[1..$], "'..."); }
55 auto gmk
= new Gmk(fname
[1..$]);
56 funcs
~= gmkLoadScripts(gmk
, doScripts
:doScripts
, doActions
:doActions
);
57 if (procgmk
!is null) procgmk(gmk
);
61 foreach (auto de; dirEntries(fname
, "*.gm[lx]", SpanMode
.breadth
)) {
63 foreach (auto pt
; pathSplitter(de.dirName
)) {
64 if (pt
.length
&& pt
[0] == '_') { doit
= false; break; }
67 if (dumpFileNames
) { import std
.stdio
; writeln("loading '", de.name
, "'..."); }
68 funcs
~= loadScript(de.name
, true);
72 if (dumpFileNames
) { import std
.stdio
; writeln("loading '", fname
, "'..."); }
73 funcs
~= loadScript(fname
, true);