forked from ground/ground
Command line arguments
This commit is contained in:
10
src/main.cpp
10
src/main.cpp
@@ -2194,6 +2194,16 @@ int main(int argc, char** argv) {
|
|||||||
cout << "Usage: " << argv[0] << " (file)" << endl;
|
cout << "Usage: " << argv[0] << " (file)" << endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get args
|
||||||
|
List argsList;
|
||||||
|
for (int i = 2; i < argc; i++) {
|
||||||
|
Literal lit;
|
||||||
|
lit.val = argv[i];
|
||||||
|
argsList.val.push_back(lit);
|
||||||
|
}
|
||||||
|
lists["args"] = argsList;
|
||||||
|
|
||||||
ifstream file(argv[1]);
|
ifstream file(argv[1]);
|
||||||
string lns;
|
string lns;
|
||||||
string in;
|
string in;
|
||||||
|
12
tests/args.grnd
Executable file
12
tests/args.grnd
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env ground
|
||||||
|
stdlnout "Program args: "
|
||||||
|
getlistsize *args &argsSize
|
||||||
|
set &counter 0
|
||||||
|
@loopstart
|
||||||
|
equal $counter $argsSize &bool
|
||||||
|
if $bool %end
|
||||||
|
getlistat *args $counter &item
|
||||||
|
stdlnout $item
|
||||||
|
add 1 $counter &counter
|
||||||
|
jump %loopstart
|
||||||
|
@end
|
Reference in New Issue
Block a user