- Introduce new 'process' module exposing a Process class with foreign static methods for accessing command-line arguments. - Implement processSetArguments in main.c to store argc/argv, and processAllArguments in process.c to return them as a Wren list. - Add --help flag support to CLI, printing usage with optional arguments. - Include documentation for Process.arguments and Process.allArguments, plus module index and template updates. - Register process module in modules.c and add Xcode project references for new source files. - Add test scripts for allArguments and arguments, verifying list type, count, and expected values.
831 B
831 B
^title Process Class
The Process class lets you work with operating processes, including the currently running one.
Static Methods
allArguments
The list of command-line arguments that were passed when the Wren process was spawned. This includes the Wren executable itself, the path to the file being run (if any), and any other options passed to Wren itself.
If you run:
:::bash
$ wren file.wren arg
This returns:
:::wren
System.print(Process.allArguments) //> ["wren", "file.wren", "arg"]
arguments
The list of command-line arguments that were passed to your program when the Wren process was spawned. This does not include arguments handled by Wren itself.
If you run:
:::bash
$ wren file.wren arg
This returns:
:::wren
System.print(Process.arguments) //> ["arg"]