shithub: mc

Download patch

ref: 26da0e6f98ac76f3930ed68649b5fbfe87c06ec4
parent: 3cdb85952401e2284ecd285742174b8f774bf18b
author: Lucas Gabriel Vuotto <lvuotto92@gmail.com>
date: Tue Jun 13 17:03:14 EDT 2017

Show usage when wrong flags are given or parameters are expected

Signed-off-by: Lucas Gabriel Vuotto <lvuotto92@gmail.com>

--- a/lib/std/optparse.myr
+++ b/lib/std/optparse.myr
@@ -113,7 +113,9 @@
 			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 @@
 			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