Stdlib/String: add Set module
This commit is contained in:
parent
6b8c3f7d31
commit
049efb2169
@ -973,8 +973,6 @@ let complete_func autocomplete cctxt =
|
|||||||
let list_command_args (Command { options = Argument { spec ; _ } ; _ }) =
|
let list_command_args (Command { options = Argument { spec ; _ } ; _ }) =
|
||||||
list_args spec
|
list_args spec
|
||||||
|
|
||||||
module StringSet = Set.Make(String)
|
|
||||||
|
|
||||||
let get_arg_parameter (type a) (arg : (a, _) arg) =
|
let get_arg_parameter (type a) (arg : (a, _) arg) =
|
||||||
match arg with
|
match arg with
|
||||||
| Arg { parameter ; _ } -> parameter
|
| Arg { parameter ; _ } -> parameter
|
||||||
@ -988,12 +986,12 @@ let complete_arg : type a ctx. ctx -> (a, ctx) arg -> string list tzresult Lwt.t
|
|||||||
| Switch _ -> return []
|
| Switch _ -> return []
|
||||||
|
|
||||||
let rec remaining_spec :
|
let rec remaining_spec :
|
||||||
type a ctx. StringSet.t -> (a, ctx) args -> string list =
|
type a ctx. TzString.Set.t -> (a, ctx) args -> string list =
|
||||||
fun seen -> function
|
fun seen -> function
|
||||||
| NoArgs -> []
|
| NoArgs -> []
|
||||||
| AddArg (arg, rest) ->
|
| AddArg (arg, rest) ->
|
||||||
let (long, _) = get_arg_parameter arg in
|
let (long, _) = get_arg_parameter arg in
|
||||||
if StringSet.mem long seen
|
if TzString.Set.mem long seen
|
||||||
then remaining_spec seen rest
|
then remaining_spec seen rest
|
||||||
else get_arg arg @ remaining_spec seen rest
|
else get_arg arg @ remaining_spec seen rest
|
||||||
|
|
||||||
@ -1018,7 +1016,7 @@ let complete_options (type ctx) continuation args args_spec ind (ctx : ctx) =
|
|||||||
if TzString.Map.mem arg arities
|
if TzString.Map.mem arg arities
|
||||||
then
|
then
|
||||||
let arity, long = TzString.Map.find arg arities in
|
let arity, long = TzString.Map.find arg arities in
|
||||||
let seen = StringSet.add long seen in
|
let seen = TzString.Set.add long seen in
|
||||||
match arity, tl with
|
match arity, tl with
|
||||||
| 0, args when ind = 0 ->
|
| 0, args when ind = 0 ->
|
||||||
continuation args 0 >>|? fun cont_args ->
|
continuation args 0 >>|? fun cont_args ->
|
||||||
@ -1028,7 +1026,7 @@ let complete_options (type ctx) continuation args args_spec ind (ctx : ctx) =
|
|||||||
| 1, _ :: tl -> help tl (ind - 2) seen
|
| 1, _ :: tl -> help tl (ind - 2) seen
|
||||||
| _ -> Pervasives.failwith "cli_entries internal error, invalid arity"
|
| _ -> Pervasives.failwith "cli_entries internal error, invalid arity"
|
||||||
else continuation args ind
|
else continuation args ind
|
||||||
in help args ind StringSet.empty
|
in help args ind TzString.Set.empty
|
||||||
|
|
||||||
let complete_next_tree cctxt = function
|
let complete_next_tree cctxt = function
|
||||||
| TPrefix { stop; prefix } ->
|
| TPrefix { stop; prefix } ->
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
(* *)
|
(* *)
|
||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
|
module Set = Set.Make (String)
|
||||||
module Map = Map.Make (String)
|
module Map = Map.Make (String)
|
||||||
|
|
||||||
let split delim ?(dup = true) ?(limit = max_int) path =
|
let split delim ?(dup = true) ?(limit = max_int) path =
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
(* *)
|
(* *)
|
||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
|
module Set : Set.S with type elt = string
|
||||||
module Map : Map.S with type key = string
|
module Map : Map.S with type key = string
|
||||||
|
|
||||||
(** Splits a string on slashes, grouping multiple slashes, and
|
(** Splits a string on slashes, grouping multiple slashes, and
|
||||||
|
Loading…
Reference in New Issue
Block a user