diff options
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/arg.ml | 12 | ||||
-rw-r--r-- | stdlib/arg.mli | 14 |
2 files changed, 16 insertions, 10 deletions
diff --git a/stdlib/arg.ml b/stdlib/arg.ml index 0d214b7a9..3cd16739f 100644 --- a/stdlib/arg.ml +++ b/stdlib/arg.ml @@ -12,10 +12,12 @@ (* $Id$ *) type spec = - String of (string -> unit) - | Int of (int -> unit) - | Unit of (unit -> unit) - | Float of (float -> unit) + Unit of (unit -> unit) (* Call the function with no argument *) + | Set of bool ref (* Set the reference to true *) + | Clear of bool ref (* Set the reference to false *) + | String of (string -> unit) (* Call the function with a string argument *) + | Int of (int -> unit) (* Call the function with an int argument *) + | Float of (float -> unit) (* Call the function with a float argument *) exception Bad of string @@ -59,6 +61,8 @@ let parse speclist anonfun = try match (action, l) with (Unit f, l) -> f (); p l + | (Set r, l) -> r := true; p l + | (Clear r, l) -> r := false; p l | (String f, arg::t) -> f arg; p t | (Int f, arg::t) -> begin try f (int_of_string arg) diff --git a/stdlib/arg.mli b/stdlib/arg.mli index d40a7068a..b7fb1a464 100644 --- a/stdlib/arg.mli +++ b/stdlib/arg.mli @@ -19,8 +19,8 @@ (* Syntax of command lines: A keyword is a character string starting with a [-]. An option is a keyword alone or followed by an argument. - There are four types of keywords: [Unit], [String], [Int], and [Float]. - [Unit] keywords do not take an argument. + There are six types of keywords: [Unit], [String], [Int], and [Float]. + [Unit], [Set_flag] and [Clear_flag] keywords do not take an argument. [String], [Int], and [Float] keywords take the following word on the command line as an argument. Arguments not preceded by a keyword are called anonymous arguments. *) @@ -34,10 +34,12 @@ *) type spec = - String of (string -> unit) - | Int of (int -> unit) - | Unit of (unit -> unit) - | Float of (float -> unit) + Unit of (unit -> unit) (* Call the function with no argument *) + | Set of bool ref (* Set the reference to true *) + | Clear of bool ref (* Set the reference to false *) + | String of (string -> unit) (* Call the function with a string argument *) + | Int of (int -> unit) (* Call the function with an int argument *) + | Float of (float -> unit) (* Call the function with a float argument *) (* The concrete type describing the behavior associated with a keyword. *) |