Skip to content

Commit

Permalink
refactor: assume Cmdliner.Arg.conv is abstract (ocaml#6609)
Browse files Browse the repository at this point in the history
`Cmdliner.Arg.conv` happens to be a pair of `parser` and `printer` but
is marked as to be made abstract. Actually the work on completion
requires making it abstract and modify it. So this PR switches to using
just the public API.

Signed-off-by: Etienne Millon <[email protected]>
  • Loading branch information
emillon authored and moyodiallo committed Dec 2, 2022
1 parent f7e8351 commit da49ea6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions bin/arg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ module Dep = struct

let parser s =
match parse_alias s with
| Some dep -> `Ok dep
| Some dep -> Ok dep
| None -> (
match
Dune_lang.Decoder.parse dep_parser Univ_map.empty
(Dune_lang.Parser.parse_string ~fname:"command line"
~mode:Dune_lang.Parser.Mode.Single s)
with
| x -> `Ok x
| exception User_error.E msg -> `Error (User_message.to_string msg))
| x -> Ok x
| exception User_error.E msg -> Error (User_message.to_string msg))

let string_of_alias ~recursive sv =
let prefix = if recursive then "@" else "@@" in
Expand All @@ -88,7 +88,7 @@ module Dep = struct
in
Format.pp_print_string ppf s

let conv = (parser, printer)
let conv = conv' (parser, printer)

let to_string_maybe_quoted t =
String.maybe_quoted (Format.asprintf "%a" printer t)
Expand Down
11 changes: 6 additions & 5 deletions bin/install_uninstall.ml
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,12 @@ let install_uninstall ~what =
let doc = Format.asprintf "%a packages." pp_what what in
let name_ = Arg.info [] ~docv:"PACKAGE" in
let absolute_path =
( (fun path ->
if Filename.is_relative path then
`Error "the path must be absolute to avoid ambiguity"
else `Ok path)
, snd Arg.string )
Arg.conv'
( (fun path ->
if Filename.is_relative path then
Error "the path must be absolute to avoid ambiguity"
else Ok path)
, Arg.conv_printer Arg.string )
in
let term =
let+ common = Common.term
Expand Down

0 comments on commit da49ea6

Please sign in to comment.