Use path argument for workspace and config file
This path argument will take paths relatively to the initial CWD Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
93fb319150
commit
02beadb856
19
bin/main.ml
19
bin/main.ml
|
@ -12,7 +12,7 @@ type common =
|
||||||
; debug_findlib : bool
|
; debug_findlib : bool
|
||||||
; debug_backtraces : bool
|
; debug_backtraces : bool
|
||||||
; profile : string option
|
; profile : string option
|
||||||
; workspace_file : string option
|
; workspace_file : Path.t option
|
||||||
; root : string
|
; root : string
|
||||||
; target_prefix : string
|
; target_prefix : string
|
||||||
; only_packages : Package.Name.Set.t option
|
; only_packages : Package.Name.Set.t option
|
||||||
|
@ -83,9 +83,7 @@ module Main = struct
|
||||||
let setup ~log ?external_lib_deps_mode common =
|
let setup ~log ?external_lib_deps_mode common =
|
||||||
setup
|
setup
|
||||||
~log
|
~log
|
||||||
?workspace_file:(
|
?workspace_file:common.workspace_file
|
||||||
Option.map common.workspace_file
|
|
||||||
~f:Path.of_filename_relative_to_initial_cwd)
|
|
||||||
?only_packages:common.only_packages
|
?only_packages:common.only_packages
|
||||||
?external_lib_deps_mode
|
?external_lib_deps_mode
|
||||||
?x:common.x
|
?x:common.x
|
||||||
|
@ -190,6 +188,11 @@ let find_root () =
|
||||||
let package_name =
|
let package_name =
|
||||||
Arg.conv ((fun p -> Ok (Package.Name.of_string p)), Package.Name.pp)
|
Arg.conv ((fun p -> Ok (Package.Name.of_string p)), Package.Name.pp)
|
||||||
|
|
||||||
|
let path_arg =
|
||||||
|
Arg.conv ((fun p -> Ok (Path.of_filename_relative_to_initial_cwd p))
|
||||||
|
, Path.pp
|
||||||
|
)
|
||||||
|
|
||||||
let common_footer =
|
let common_footer =
|
||||||
`Blocks
|
`Blocks
|
||||||
[ `S "BUGS"
|
[ `S "BUGS"
|
||||||
|
@ -256,7 +259,7 @@ let common =
|
||||||
let orig_args =
|
let orig_args =
|
||||||
List.concat
|
List.concat
|
||||||
[ dump_opt "--profile" profile
|
[ dump_opt "--profile" profile
|
||||||
; dump_opt "--workspace" workspace_file
|
; dump_opt "--workspace" (Option.map ~f:Path.to_string workspace_file)
|
||||||
; orig
|
; orig
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
|
@ -433,7 +436,7 @@ let common =
|
||||||
in
|
in
|
||||||
let workspace_file =
|
let workspace_file =
|
||||||
Arg.(value
|
Arg.(value
|
||||||
& opt (some file) None
|
& opt (some path_arg) None
|
||||||
& info ["workspace"] ~docs ~docv:"FILE"
|
& info ["workspace"] ~docs ~docv:"FILE"
|
||||||
~doc:"Use this specific workspace file instead of looking it up.")
|
~doc:"Use this specific workspace file instead of looking it up.")
|
||||||
in
|
in
|
||||||
|
@ -470,7 +473,7 @@ let common =
|
||||||
let config_file =
|
let config_file =
|
||||||
let config_file =
|
let config_file =
|
||||||
Arg.(value
|
Arg.(value
|
||||||
& opt (some file) None
|
& opt (some path_arg) None
|
||||||
& info ["config-file"] ~docs ~docv:"FILE"
|
& info ["config-file"] ~docs ~docv:"FILE"
|
||||||
~doc:"Load this configuration file instead of the default one.")
|
~doc:"Load this configuration file instead of the default one.")
|
||||||
in
|
in
|
||||||
|
@ -483,7 +486,7 @@ let common =
|
||||||
let merge config_file no_config =
|
let merge config_file no_config =
|
||||||
match config_file, no_config with
|
match config_file, no_config with
|
||||||
| None , false -> `Ok (None , Default)
|
| None , false -> `Ok (None , Default)
|
||||||
| Some fn, false -> `Ok (Some "--config-file", This (Path.of_string fn))
|
| Some fn, false -> `Ok (Some "--config-file", This fn)
|
||||||
| None , true -> `Ok (Some "--no-config" , No_config)
|
| None , true -> `Ok (Some "--no-config" , No_config)
|
||||||
| Some _ , true -> incompatible "--no-config" "--config-file"
|
| Some _ , true -> incompatible "--no-config" "--config-file"
|
||||||
in
|
in
|
||||||
|
|
Loading…
Reference in New Issue