args — command-line arguments
Reads the command-line arguments the program received. Arguments are not a value visible everywhere; they are a capability handed to main, which is why the first input is cap args (chapter 16). The module is one wrapper that passes the builtin op arg through.
use args .
proc first_len input a cap args . output usize . effects none . do
let who option slice u8 args.get a. 0 . .
guard is_some who. . else return 0 . .
return len some_value who. . . .
end .| op | shape | notes |
|---|---|---|
arg | (cap args, i u64) → option slice u8 | The i-th argument, from 0. none when there is no argument at that position |
Table 50.1 — The ops of args
The number of arguments comes from the core op len a. . (the same word as the length of a slice).
Not built: option parsing (--name value), reading an argument as a number.