summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2018-10-19 17:38:51 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2018-10-19 17:38:51 -0400
commit39497fe7d80a6765b131b0a62ab48db8bd47a8e9 (patch)
tree104259e7a2b441572cfd6ffba90c318ef9f88aec
parent31b7eea8489d84ae3abdb068aaf15a6fcdb02124 (diff)
Accept a few other command-line arguments to trigger help text (closes #63)
-rw-r--r--src/main.mlton.sml23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/main.mlton.sml b/src/main.mlton.sml
index 1229d552..57e89ef2 100644
--- a/src/main.mlton.sml
+++ b/src/main.mlton.sml
@@ -43,14 +43,25 @@ fun parse_flags flag_info args =
fn (flag1, _, _) => flag0 = flag1
end
+ fun normalizeArg arg =
+ case arg of
+ "-h" => "-help"
+ | "--h" => "-help"
+ | "--help" => "-help"
+ | _ => arg
+
fun loop [] : string list = []
| loop (arg :: args) =
- if String.isPrefix "-" arg then
- case List.find (search_pred arg) flag_info of
- NONE => raise Fail ("Unknown flag "^arg^", see -help")
- | SOME x => exec x args
- else
- arg :: loop args
+ let
+ val arg = normalizeArg arg
+ in
+ if String.isPrefix "-" arg then
+ case List.find (search_pred arg) flag_info of
+ NONE => raise Fail ("Unknown flag "^arg^", see -help")
+ | SOME x => exec x args
+ else
+ arg :: loop args
+ end
and exec (_, ZERO f, _) args =
(f (); loop args)