From 1128450d0b52c09e78d64df5737b8a034b3e230c Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Sun, 5 Nov 2023 11:23:08 +0100 Subject: Fixup in the --help message --- bin/args.ml | 12 +++++++----- bin/qsp_parser.ml | 14 +++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'bin') diff --git a/bin/args.ml b/bin/args.ml index a98981c..54751c8 100644 --- a/bin/args.ml +++ b/bin/args.ml @@ -40,9 +40,7 @@ let enable_module modules identifier = let (module C : Qsp_syntax.S.Analyzer) = Qsp_syntax.Check.get_module t in if String.equal C.identifier identifier then C.active := true) -let speclist modules printer = - ignore modules; - +let speclist printer = let common_arguments = [ ( "--version", @@ -64,7 +62,7 @@ let speclist modules printer = Arg.Set reset_line, "\tEach line is refered from the begining of the file and not the \ location" ); - ("-", Arg.String anon_fun, "\tDisable this test"); + ("-", Arg.Unit (fun () -> ()), "\tDisable this test"); ("+", Arg.Unit (fun () -> ()), "\tEnable this test"); ] and windows_arguments = @@ -80,13 +78,17 @@ let parse : list_tests:(Format.formatter -> unit) -> string list * t = fun ~modules ~list_tests -> - let speclist = speclist modules list_tests in + let speclist = speclist list_tests in let speclist = let r = ref speclist in for i = 1 to pred (Array.length Sys.argv) do let s = Sys.argv.(i) in if s.[0] = '-' + && String.length s > 1 + && s.[1] != '-' + && (not (String.equal s "--help")) + && (not (String.equal s "-help")) && not (List.exists !r ~f:(fun (s', _, _) -> String.equal s s')) then r := diff --git a/bin/qsp_parser.ml b/bin/qsp_parser.ml index 1b2b90c..70f474e 100644 --- a/bin/qsp_parser.ml +++ b/bin/qsp_parser.ml @@ -48,7 +48,7 @@ let pp_modules formatter = (* Print the name, left justified, with enought spaces for the all the identifiers *) - Format.fprintf formatter "%-*s" (max_length + 1) "Name"; + Format.fprintf formatter "%-*s" (succ max_length) "Name"; (* Tab delimiter *) Format.pp_set_tab formatter (); Format.fprintf formatter "Active "; @@ -65,6 +65,10 @@ let pp_modules formatter = Format.pp_close_tbox formatter (); Format.pp_print_break formatter 0 0 +(** Get all the tests to apply. + + The expression is declared lazy in order to be sure to apply the filters + from the command line before. *) let checkers : (module Qsp_syntax.S.Analyzer) Lazy.t = lazy (let module Check = Qsp_syntax.Check.Make (struct @@ -102,14 +106,14 @@ let parse_location : ctx:ctx -> Qparser.Lexbuf.t -> Args.filters -> ctx = List.fold_left report ~init:ctx ~f:(fun ctx report -> match report.Report.level with - | Error -> { ctx with error_nb = ctx.error_nb + 1 } - | Warn -> { ctx with warn_nb = ctx.warn_nb + 1 } - | Debug -> { ctx with debug_nb = ctx.debug_nb + 1 })) + | Error -> { ctx with error_nb = succ ctx.error_nb } + | Warn -> { ctx with warn_nb = succ ctx.warn_nb } + | Debug -> { ctx with debug_nb = succ ctx.debug_nb })) | Error e -> let start_position, _ = Qparser.Lexbuf.positions lexbuf in Format.fprintf Format.std_formatter "Location@ %s@;@[%a]@." start_position.Lexing.pos_fname Report.pp e; - { ctx with error_nb = ctx.error_nb + 1 } + { ctx with error_nb = succ ctx.error_nb } let default_ctx = { error_nb = 0; warn_nb = 0; debug_nb = 0 } -- cgit v1.2.3