Skip to content

Commit

Permalink
Adding "float" argument type
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorNicollet committed May 4, 2012
1 parent ff9ea6c commit 468026b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/action.mli
Expand Up @@ -233,6 +233,9 @@ module Args : sig
(** An integer cell. *)
val int : int cell

(** A floating-point cell. *)
val float : float cell

(** The type of an argument parser.
*)
type 'args t = ('args -> string list) * (string list -> 'args option)
Expand Down
3 changes: 2 additions & 1 deletion src/action_Args.ml
Expand Up @@ -2,7 +2,8 @@ type 'a cell = ('a -> string) * (string -> 'a option)
type 'args t = ('args -> string list) * (string list -> 'args option)

let string = (fun str -> str), (fun str -> Some str)
let int = string_of_int, (fun i -> try Some (int_of_string i) with _ -> None)
let int = string_of_int, (fun i -> try Some ( int_of_string i) with _ -> None)
let float = string_of_float, (fun i -> try Some (float_of_string i) with _ -> None)

let parse (_,f) list = f list
let generate (g,_) args = g args
Expand Down

0 comments on commit 468026b

Please sign in to comment.