From da49ea63ff59c11cbcfd1b1d10664a503d985b48 Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Wed, 30 Nov 2022 15:41:58 +0100 Subject: [PATCH] refactor: assume Cmdliner.Arg.conv is abstract (#6609) `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 --- bin/arg.ml | 8 ++++---- bin/install_uninstall.ml | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/arg.ml b/bin/arg.ml index 27242ccf9cbf..fa5e4b1c8864 100644 --- a/bin/arg.ml +++ b/bin/arg.ml @@ -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 @@ -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) diff --git a/bin/install_uninstall.ml b/bin/install_uninstall.ml index 826439fea470..287bd161b13c 100644 --- a/bin/install_uninstall.ml +++ b/bin/install_uninstall.ml @@ -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