more core docs
[io.git] / libs / iovm / io / System.io
bloba82ca42bedf6f21b71b3b8e2ff4b02fb294991b4
1 System do(
2 launchScript := nil
3 docSlot("launchScript", "Returns the path of the io file run on the command line. Returns nil if no file was run.")
5 ioPath := installPrefix asMutable appendPathSeq("lib") appendPathSeq("io")
6 docSlot("ioPath", "Returns the path of io installation. The default is $INSTALL_PREFIX/lib/io.")
8 docSlot("getOptions(args)", "
9 This primitive is used to get command line options similar to Cs getopt().
10 It returns a map in containing the left side of the argument, with the
11 value of the right side. (The key will not contain
12 the beginning dashes (--).
13 <p>
14 Example:
15 <pre>
16 options := System getOptions(args)
17 options foreach(k, v,
18 if(v type == List type,
19 v foreach(i, j, writeln(\"Got unnamed argument with value: \" .. j))
20 continue
22 writeln(\"Got option: \" .. k .. \" with value: \" .. v)
24 </pre>
27 getOptions := method(arguments,
28 opts := Map clone
29 optname := Sequence clone
30 optvalue := Sequence clone
31 optsNoKey := List clone
33 arguments foreach(i, arg,
34 if(arg beginsWithSeq("--") isNil,
35 optsNoKey append(arg)
36 continue
39 if(arg containsSeq("=")) then(
40 optname := arg clone asMutable
41 optname clipAfterStartOfSeq("=")
42 optname clipBeforeEndOfSeq("--")
43 optvalue := arg clone asMutable
44 optvalue clipBeforeEndOfSeq("=")
45 ) else(
46 optname := arg clone asMutable
47 optname clipBeforeEndOfSeq("--")
48 optvalue = ""
50 opts atPut(optname, optvalue)
53 if(optsNoKey last != nil, opts atPut("", optsNoKey))
54 opts