summaryrefslogtreecommitdiff
path: root/lib/std/optparse.myr
diff options
context:
space:
mode:
authorLucas Gabriel Vuotto <lvuotto92@gmail.com>2017-06-13 21:03:14 -0300
committerOri Bernstein <ori@markovcorp.com>2017-06-13 17:13:38 -0700
commit26da0e6f98ac76f3930ed68649b5fbfe87c06ec4 (patch)
treea7d76588e449b330605bec6e11bc370e8c8863c0 /lib/std/optparse.myr
parent3cdb85952401e2284ecd285742174b8f774bf18b (diff)
downloadmc-26da0e6f98ac76f3930ed68649b5fbfe87c06ec4.tar.gz
Show usage when wrong flags are given or parameters are expected
Signed-off-by: Lucas Gabriel Vuotto <lvuotto92@gmail.com>
Diffstat (limited to 'lib/std/optparse.myr')
-rw-r--r--lib/std/optparse.myr7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/std/optparse.myr b/lib/std/optparse.myr
index 4e67dce..083c7f5 100644
--- a/lib/std/optparse.myr
+++ b/lib/std/optparse.myr
@@ -113,7 +113,9 @@ const optnext = {ctx
optusage(ctx.optargs[0], ctx.optdef)
exit(0)
else
- fatal("unexpected argument '{}'\n", c)
+ put("Unexpected argument '{}'\n", c)
+ optusage(ctx.optargs[0], ctx.optdef)
+ exit(1)
;;
| `Some (true, needed, dest):
/* -arg => '-a' 'rg' */
@@ -127,7 +129,8 @@ const optnext = {ctx
ctx.argidx++
next(ctx)
elif needed
- put("Expected argument for {}\n", c)
+ put("Expected argument for '{}'\n", c)
+ optusage(ctx.optargs[0], ctx.optdef)
exit(1)
;;
match dest