1 (* Copyright (C) 2009,2017 Matthew Fluet.
2 * Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 * Copyright (C) 1997-2000 NEC Research Institute.
6 * MLton is released under a BSD-style license.
7 * See the file MLton-LICENSE for details.
12 (* This type specifies what kind of arguments a switch expects
13 * and provides the function to be applied to the argument.
16 (* one arg: a boolean (true, false), after a space *)
18 (* one arg: a single digit, no space. *)
19 | Digit of int -> unit
20 (* one arg: an integer, after a space *)
22 (* one arg: an integer followed by optional k or m. *)
25 | None of unit -> unit
26 | Real of real -> unit
27 (* Any string immediately follows the switch. *)
28 | String of string -> unit
29 (* one arg: any string, after a space *)
30 | SpaceString of string -> unit
31 | SpaceString2 of string * string -> unit
32 (* one arg: a word (hex), after a space *)
33 | Word of word -> unit
35 val boolRef: bool ref -> t
36 val falseRef: bool ref -> t
37 val intRef: int ref -> t
38 val stringRef: string ref -> t
39 val trueRef: bool ref -> t
40 val wordRef: word ref -> t
44 (* Parse the switches, applying the first matching t to each switch,
45 * and return any remaining args.
46 * Returns NONE if it encounters an error.
47 * For example, if ts is:
49 * and the switches are:
51 * then parse will call f() and return "bar".
55 switches: string list,
56 opts: (string * t) list
58 -> string list Result.t
60 datatype optionStyle = Normal | Expert
61 val makeUsage: {mainUsage: string,
62 makeOptions: ({usage: string -> unit}
63 -> {style: optionStyle,
68 showExpert: unit -> bool
69 } -> {parse: string list -> string list Result.t,
70 usage: string -> unit}