diff options
author | Chimrod <> | 2023-10-03 08:32:14 +0200 |
---|---|---|
committer | Chimrod <> | 2023-10-03 08:32:14 +0200 |
commit | c7683b81be07f76ab8f1bfb95273291720eb017c (patch) | |
tree | 25858ba49bb71e5e3e08dce51f7eff4d832fadfa /bin/args.ml | |
parent | f21a7b0552f65de232ab75bdd3172c6c182292b1 (diff) |
Handle the case where no args are given
Diffstat (limited to 'bin/args.ml')
-rw-r--r-- | bin/args.ml | 20 |
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 } ) |