diff options
author | Ori Bernstein <ori@eigenstate.org> | 2015-05-01 14:59:53 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2015-05-01 14:59:53 -0700 |
commit | cca9d66940c892e52559bfb2f71dcec92e4ddc46 (patch) | |
tree | f21844c84b55d4ff754331c4ba712e3ad07007a1 | |
parent | 9eb9766c7d1a59d9d2a239dcfcd6ab67d2417cf9 (diff) | |
download | mc-cca9d66940c892e52559bfb2f71dcec92e4ddc46.tar.gz |
Add support for '--' to end arg parsing.
-rw-r--r-- | libstd/optparse.myr | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libstd/optparse.myr b/libstd/optparse.myr index 63d87f7..7bd0739 100644 --- a/libstd/optparse.myr +++ b/libstd/optparse.myr @@ -3,9 +3,10 @@ use "die.use" use "extremum.use" use "fmt.use" use "option.use" +use "sleq.use" use "slpush.use" -use "syswrap.use" use "syswrap-ss.use" +use "syswrap.use" use "types.use" use "utf.use" @@ -128,11 +129,16 @@ const next = {ctx for i = ctx.argidx + 1; i < ctx.optargs.len; i++ if !ctx.optdone && decode(ctx.optargs[i]) == '-' - goto foundopt + if sleq(ctx.optargs[i], "--") + ctx.optdone = true + else + goto foundopt + ;; else ctx.args = slpush(ctx.args, ctx.optargs[i]) ;; ;; +:finishedopt ctx.finished = true -> false :foundopt @@ -150,7 +156,7 @@ const optusage = {ctx std.put("\t-h\tprint this help message\n") std.put("\t-?\tprint this help message\n") for o in ctx.optdef.opts - std.put("\t%c%s%s\t%s\n", o.opt, sep(o.arg), o.arg, o.desc) + std.put("\t-%c%s%s\t%s\n", o.opt, sep(o.arg), o.arg, o.desc) ;; } |