diff options
| author | Enrico Tassi | 2014-09-08 11:36:44 +0200 |
|---|---|---|
| committer | Enrico Tassi | 2014-09-09 13:11:38 +0200 |
| commit | 4d601a87b775529b7d516fa213c688b6ecf5246d (patch) | |
| tree | 0f6f2c716f3bbb8cf25032b30e4af42a223ded69 /lib | |
| parent | 938dd9ba81d0bba5a9358627405d3110fc4ee335 (diff) | |
toploop plugins taken into account when printing --help (close: 3535)
E.g.
Coq options are:
-I dir look for ML files in dir
-include dir (idem)
[...]
-h, --help print this list of options
With the flag '-toploop coqidetop' these extra option are also available:
--help-XML-protocol print the documentation of the XML protocol used by CoqIDE
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/system.ml | 26 | ||||
| -rw-r--r-- | lib/system.mli | 5 |
2 files changed, 22 insertions, 9 deletions
diff --git a/lib/system.ml b/lib/system.ml index 511b84ab4b..a2f339b1d3 100644 --- a/lib/system.ml +++ b/lib/system.ml @@ -53,14 +53,12 @@ let all_subdirs ~unix_path:root = if exists_dir root then traverse root []; List.rev !l +let rec search paths test = + match paths with + | [] -> [] + | lpe :: rem -> test lpe @ search rem test + let where_in_path ?(warn=true) path filename = - let rec search = function - | lpe :: rem -> - let f = Filename.concat lpe filename in - if Sys.file_exists f - then (lpe,f) :: search rem - else search rem - | [] -> [] in let check_and_warn l = match l with | [] -> raise Not_found | (lpe, f) :: l' -> @@ -77,7 +75,19 @@ let where_in_path ?(warn=true) path filename = in (lpe, f) in - check_and_warn (search path) + check_and_warn (search path (fun lpe -> + let f = Filename.concat lpe filename in + if Sys.file_exists f then [lpe,f] else [])) + +let where_in_path_rex path rex = + search path (fun lpe -> + let files = Sys.readdir lpe in + CList.map_filter (fun name -> + try + ignore(Str.search_forward rex name 0); + Some (lpe,Filename.concat lpe name) + with Not_found -> None) + (Array.to_list files)) let find_file_in_path ?(warn=true) paths filename = if not (Filename.is_implicit filename) then diff --git a/lib/system.mli b/lib/system.mli index af797121a3..e4f344f6b4 100644 --- a/lib/system.mli +++ b/lib/system.mli @@ -19,7 +19,10 @@ val exclude_search_in_dirname : string -> unit val all_subdirs : unix_path:string -> (CUnix.physical_path * string list) list val is_in_path : CUnix.load_path -> string -> bool val is_in_system_path : string -> bool -val where_in_path : ?warn:bool -> CUnix.load_path -> string -> CUnix.physical_path * string +val where_in_path : + ?warn:bool -> CUnix.load_path -> string -> CUnix.physical_path * string +val where_in_path_rex : + CUnix.load_path -> Str.regexp -> (CUnix.physical_path * string) list val exists_dir : string -> bool |
