aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChimrod <>2023-10-03 08:32:14 +0200
committerChimrod <>2023-10-03 08:32:14 +0200
commitc7683b81be07f76ab8f1bfb95273291720eb017c (patch)
tree25858ba49bb71e5e3e08dce51f7eff4d832fadfa
parentf21a7b0552f65de232ab75bdd3172c6c182292b1 (diff)
Handle the case where no args are given
-rw-r--r--bin/args.ml20
1 files changed, 16 insertions, 4 deletions
diff --git a/bin/args.ml b/bin/args.ml
index e4e892c..90d65de 100644
--- a/bin/args.ml
+++ b/bin/args.ml
@@ -1,7 +1,10 @@
module Report = Qsp_syntax.Report
let input_files = ref []
-let usage = "qsp_parser input_file"
+
+let usage =
+ Printf.sprintf "%s input_file" (Filename.basename Sys.executable_name)
+
let anon_fun filename = input_files := filename :: !input_files
let level_value = ref None
let reset_line = ref false
@@ -53,6 +56,15 @@ let speclist =
let parse : unit -> string list * t =
fun () ->
let () = Arg.parse (Arg.align speclist) anon_fun usage in
- let filters = { level = !level_value } in
- ( !input_files,
- { reset_line = !reset_line; filters; interractive = !interractive } )
+
+ match !input_files with
+ | [] ->
+ Arg.usage (Arg.align speclist) usage;
+ prerr_endline "";
+ prerr_endline "Error, you should provide at least one file to parse.";
+
+ exit 1
+ | _ ->
+ let filters = { level = !level_value } in
+ ( !input_files,
+ { reset_line = !reset_line; filters; interractive = !interractive } )