OCaml: Handle some edge cases; refactor parser, main.ml; add config fetcher
This commit is contained in:
parent
6096817932
commit
cb56da1462
16 changed files with 229 additions and 105 deletions
|
|
@ -1,24 +1,14 @@
|
|||
open Tori.Utilities.Aliases
|
||||
|
||||
module ConfigLexer = Tori.Parsers.Config.Lexer
|
||||
module ConfigParser = Tori.Parsers.Config.Parser
|
||||
|
||||
let config_file =
|
||||
ConfigLexer.read $ Unix.getenv "HOME" ^ "/.config/tori/tori.conf"
|
||||
module ConfigFetcher = Tori.Parsers.Config.Fetcher
|
||||
|
||||
let () =
|
||||
|
||||
(* TODO: extract *)
|
||||
let tokens = ConfigLexer.scan config_file in
|
||||
(* elog $ ConfigLexer.string_of_tokens tokens; *)
|
||||
let config = ConfigParser.parse (List.concat tokens) in
|
||||
(* elog $ ConfigParser.string_of_config config; *)
|
||||
|
||||
match Array.to_list Sys.argv with
|
||||
| _ :: tail ->
|
||||
let past = ConfigParser.apply Tori.Schema.origin config in
|
||||
let future = Tori.Parsers.Argument.interpret past tail in
|
||||
if future.output.main <> "" then print_endline future.output.main;
|
||||
if future.output.log <> "" then elog future.output.log;
|
||||
let past = ConfigFetcher.fetch Tori.Schema.origin
|
||||
|> Tori.Checks.post_config
|
||||
in
|
||||
let future = Tori.Parsers.Argument.interpret past tail
|
||||
|> Tori.Checks.exit
|
||||
in
|
||||
exit future.meta.status
|
||||
| [] -> assert false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue