diff options
Diffstat (limited to 'lib/config.ml')
-rw-r--r-- | lib/config.ml | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/config.ml b/lib/config.ml index 61810fa..fb1fc88 100644 --- a/lib/config.ml +++ b/lib/config.ml @@ -1,2 +1,26 @@ -let git_directory = Filename.concat (Unix.getenv "HOME") "git.test" -let author = "Marius Peter" +let config_file = "default_config.toml" + +type t = { + repositories_root : string; + user : string; + default_branch : string; + max_commits_displayed : int; +} + +let config = + match Toml.Parser.from_filename config_file with + | `Error (e, _) -> failwith ("Config parse error: " ^ e) + | `Ok table -> + let find key = Toml.Types.Table.find (Toml.Min.key key) table in + let find_string key = + match find key with TString s -> s | _ -> raise Not_found + in + let find_int key = + match find key with TInt i -> i | _ -> raise Not_found + in + { + repositories_root = find_string "repositories_root"; + user = find_string "user"; + default_branch = find_string "default_branch"; + max_commits_displayed = find_int "max_commits_displayed"; + } |