diff --git a/ocaml/bin/main.ml b/ocaml/bin/main.ml index 1e586af..7f6b4bf 100644 --- a/ocaml/bin/main.ml +++ b/ocaml/bin/main.ml @@ -2,5 +2,6 @@ let () = match Array.to_list Sys.argv with | _ :: tail -> let future = (Tori.Parsers.Argument.interpret Tori.Schema.seed tail) in - if future.output.message <> "" then print_endline future.output.message + if future.output.message <> "" then print_endline future.output.message; + exit future.meta.status | [] -> assert false diff --git a/ocaml/lib/parsers/argument.ml b/ocaml/lib/parsers/argument.ml index d068145..5d12749 100644 --- a/ocaml/lib/parsers/argument.ml +++ b/ocaml/lib/parsers/argument.ml @@ -2,7 +2,6 @@ let interpret (past: Schema.schema) (input: string list): Schema.schema = let future = { past with output = { message = "" } } in - (* say is useful when the only change to future is the output message *) let say (message: string) = { future with output = { message = message } } in @@ -19,5 +18,12 @@ let interpret (past: Schema.schema) (input: string list): Schema.schema = say (Schema.format_version future.meta.version) | ("help" | "-h" | "--help") :: _ -> say future.meta.help.long | head :: _ -> - say ("Unrecognized command: " ^ head ^ "\n" ^ future.meta.help.short) + { future with + output = { + message = + ("Unrecognized command: " ^ head ^ "\n" + ^ future.meta.help.short) + }; + meta = { future.meta with status = 1 }; + } | _ -> future diff --git a/ocaml/lib/schema/schema.ml b/ocaml/lib/schema/schema.ml index ed09ccb..b10b05f 100644 --- a/ocaml/lib/schema/schema.ml +++ b/ocaml/lib/schema/schema.ml @@ -2,7 +2,7 @@ open Qol type version = { major: int; minor: int; patch: int } type help = { short: string; long: string } -type meta = { version: version; help: help } +type meta = { version: version; help: help; status: int } type output = { message: string; } @@ -22,6 +22,7 @@ let seed: schema = { short = ""; long = ""; }; + status = 0; }; output = { message = "";