shithub: mc

Download patch

ref: 2c5db83da78a650e5dd01740e28946d682b23604
parent: a0172160d6cde82a878dfdcaafec6cd3f950b708
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Jun 28 09:39:54 EDT 2016

Improve error messages for formatting issues.

--- a/lib/std/fmt.myr
+++ b/lib/std/fmt.myr
@@ -204,7 +204,7 @@
 
 const parseparams = {paramstr, optdesc
 	var params, opts
-	var o, a, ha : bool, gotarg : bool
+	var o, a, ha, gotarg, found
 
 	opts = [][:]
 	if optdesc.len == 0 && paramstr.len > 0
@@ -224,17 +224,26 @@
 			gotarg = false
 		;;
 
+		found = false
 		/* verify and add the arg */
 		for (opt, hasarg) in optdesc
 			if !std.sleq(opt, o)
 				continue
 			;;
+			found = true
 			ha = hasarg
 			if ha == gotarg
 				std.slpush(&opts, (o, a))
 			else
-				std.fatal("invalid option {} ", o)
+				std.fatal("invalid arg for option {} ", a, o)
 			;;
+		;;
+		if !found
+			std.put("options: \n")
+			for (opt, hasarg) in optdesc
+				std.put("\t'{}', hasarg={}\n", opt, hasarg)
+			;;
+			std.fatal("invalid option '{}' ", o)
 		;;
 	;;
 	slfree(params)