From 1b918de26a36a4e79ab8df51f08d323743dcddd0 Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Wed, 30 Nov 2022 11:32:20 +0100 Subject: [PATCH] refactor: assume Cmdliner.Arg.conv is abstract `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 27242ccf9cb..fa5e4b1c886 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 826439fea47..287bd161b13 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