@@ -7,12 +7,39 @@ open Fiber.O
77 bootstrap, so we set this reference here *)
88let () = suggest_function := Cmdliner_suggest. value
99
10+ module Arg = struct
11+ include Arg
12+
13+ let package_name =
14+ Arg. conv ((fun p -> Ok (Package.Name. of_string p)), Package.Name. pp)
15+
16+ module Path : sig
17+ type t
18+ val path : t -> Path .t
19+ val arg : t -> string
20+
21+ val conv : t conv
22+ end = struct
23+ type t = string
24+
25+ let path p = Path. of_filename_relative_to_initial_cwd p
26+ let arg s = s
27+
28+ let conv = Arg. conv ((fun p -> Ok p), Format. pp_print_string)
29+ end
30+
31+ let path = Path. conv
32+
33+ [@@@ ocaml.warning " -32" ]
34+ let file = path
35+ end
36+
1037type common =
1138 { debug_dep_path : bool
1239 ; debug_findlib : bool
1340 ; debug_backtraces : bool
1441 ; profile : string option
15- ; workspace_file : string option
42+ ; workspace_file : Arg.Path .t option
1643 ; root : string
1744 ; target_prefix : string
1845 ; only_packages : Package.Name.Set .t option
@@ -83,8 +110,7 @@ module Main = struct
83110 let setup ~log ?external_lib_deps_mode common =
84111 setup
85112 ~log
86- ?workspace_file:(
87- Option. map common.workspace_file ~f: Path. of_string)
113+ ?workspace_file:(Option. map ~f: Arg.Path. path common.workspace_file)
88114 ?only_packages:common.only_packages
89115 ?external_lib_deps_mode
90116 ?x:common.x
@@ -186,9 +212,6 @@ let find_root () =
186212 in
187213 (dir, to_cwd)
188214
189- let package_name =
190- Arg. conv ((fun p -> Ok (Package.Name. of_string p)), Package.Name. pp)
191-
192215let common_footer =
193216 `Blocks
194217 [ `S " BUGS"
@@ -255,7 +278,7 @@ let common =
255278 let orig_args =
256279 List. concat
257280 [ dump_opt " --profile" profile
258- ; dump_opt " --workspace" workspace_file
281+ ; dump_opt " --workspace" ( Option. map ~f: Arg.Path. arg workspace_file)
259282 ; orig
260283 ]
261284 in
@@ -432,7 +455,7 @@ let common =
432455 in
433456 let workspace_file =
434457 Arg. (value
435- & opt (some file ) None
458+ & opt (some path ) None
436459 & info [" workspace" ] ~docs ~docv: " FILE"
437460 ~doc: " Use this specific workspace file instead of looking it up." )
438461 in
@@ -469,7 +492,7 @@ let common =
469492 let config_file =
470493 let config_file =
471494 Arg. (value
472- & opt (some file ) None
495+ & opt (some path ) None
473496 & info [" config-file" ] ~docs ~docv: " FILE"
474497 ~doc: " Load this configuration file instead of the default one." )
475498 in
@@ -482,7 +505,7 @@ let common =
482505 let merge config_file no_config =
483506 match config_file, no_config with
484507 | None , false -> `Ok (None , Default )
485- | Some fn , false -> `Ok (Some " --config-file" , This (Path. of_string fn))
508+ | Some fn , false -> `Ok (Some " --config-file" , This (Arg. Path.path fn))
486509 | None , true -> `Ok (Some " --no-config" , No_config )
487510 | Some _ , true -> incompatible " --no-config" " --config-file"
488511 in
0 commit comments