crunch config
This commit is contained in:
parent
67a2282141
commit
fd937fbc2f
3 changed files with 13 additions and 7 deletions
|
|
@ -16,7 +16,7 @@ type section = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let fail_with msg =
|
let fail_with msg =
|
||||||
Fmt.epr "Failed to parse configuration: %s.@." msg;
|
Fmt.epr "Configuration failure: %s.@." msg;
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
let is_eol = function '\n' | '\r' -> true | _ -> false
|
let is_eol = function '\n' | '\r' -> true | _ -> false
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
open Parse_config
|
open Parse_config
|
||||||
|
|
||||||
let config_data =
|
let config_data =
|
||||||
let read_file file = In_channel.with_open_bin file In_channel.input_all in
|
let path = Fpath.to_string (Fpath.v "default.config") in
|
||||||
let content = read_file "default.config" in
|
match Assets_crunch.read path with
|
||||||
let v = Parse_data.parse content in
|
| None -> Fmt.failwith "static file not found: `%s`" path
|
||||||
|
| Some data ->
|
||||||
|
let v = Parse_data.parse data in
|
||||||
(*Fmt.epr "config file:@\n%a@." Pp_debug.pp_config v;*)
|
(*Fmt.epr "config file:@\n%a@." Pp_debug.pp_config v;*)
|
||||||
v
|
v
|
||||||
|
|
||||||
|
|
@ -119,7 +121,11 @@ module Currency = struct
|
||||||
(Fmt.str
|
(Fmt.str
|
||||||
"section `[currency-%s]` not found, currency `%s` is not defined"
|
"section `[currency-%s]` not found, currency `%s` is not defined"
|
||||||
Exchange.currency Exchange.currency)
|
Exchange.currency Exchange.currency)
|
||||||
| Some v -> v
|
| Some v -> (
|
||||||
|
match v.enabled = `YES with
|
||||||
|
| false ->
|
||||||
|
fail_with (Fmt.str "currency `%s` is not enabled" Exchange.currency)
|
||||||
|
| true -> v)
|
||||||
end
|
end
|
||||||
|
|
||||||
module Coin = struct
|
module Coin = struct
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue