Command-prompt arguments
You can access command-prompt arguments to Gosu programs by manipulating raw arguments. You can parse the full list
of arguments from the command line as positional parameters. Alternatively, you can write a custom parser to
identify named options and their values. For example, you can write a parser for an option that has multiple parts
that are separated by space characters, such as -username jsmith. In this example, each of the
-username and the jsmith components is a separate raw argument.
To get the full list of command-prompt arguments as a list of String values, use the
RawArgs property of the gw.lang.Gosu class. This property provides an array
of String values. You can access the values in this array in the same way as any other array. For
example, you can use Gosu code like the following lines.
// TestArgs.gsp
var myArgs = Gosu.RawArgs
var numArgs = myArgs.Count
print("${myArgs} ${numArgs}")
for (str in myArgs) {
print("${str}")
}
You can run the program with the following command.
TestArgs one two three
This code prints the following lines.
[one, two, three] 3
one
two
three