X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=psi.d%2Fgetopt.psi;fp=psi.d%2Fgetopt.psi;h=5f5bae6fcb67d6ac3224e55b94837d8b6589a502;hp=0000000000000000000000000000000000000000;hb=a107dfcca2dfd0fc5a2779a8d679f778cb8f3290;hpb=dfc032e7e195fc09c5ad2cda81d00a8958b80a66 diff --git a/psi.d/getopt.psi b/psi.d/getopt.psi new file mode 100644 index 0000000..5f5bae6 --- /dev/null +++ b/psi.d/getopt.psi @@ -0,0 +1,24 @@ +function psi\opterr() : int { + return to_int(opterr); +} +function psi\optind() : int { + return to_int(optind); +} +function psi\optopt() : int { + return to_int(optopt); +} +function psi\optarg() : string { + return to_string(optarg); +} + +function psi\getopt(array &$argv, string $options) : int { + let argc = count($argv); + let argv = &arrval($argv, + *argv = strval($argv) + ); + let optstring = strval($options); + return to_int(getopt); + set $argv = to_array(argv, + to_string(argv) + ); +}