Commit
Author: Kevin Schoon [kevinschoon@gmail.com]
Hash: f64b886f4fbc974deef972edd2b12d04d40720b9
Timestamp: Sat, 26 Sep 2020 23:55:44 +0000 (4 years ago)

+7 -4 +/-2 browse
flags default to configuration value
1diff --git a/lib/cmd.ml b/lib/cmd.ml
2index f0243c8..3818bdd 100644
3--- a/lib/cmd.ml
4+++ b/lib/cmd.ml
5 @@ -48,7 +48,8 @@ note cat -encoding json
6 ~doc:"perform a fulltext search instead of just key comparison"
7 and encoding =
8 flag "encoding"
9- (optional_with_default Encoding.Raw
10+ (optional_with_default
11+ (Encoding.of_string (value_as_string (get load Key.Encoding)))
12 (Command.Arg_type.create Encoding.of_string))
13 ~doc:"format [json | yaml | raw] (default: raw)"
14 in
15 @@ -225,7 +226,8 @@ note ls
16 ~doc:"perform a fulltext search instead of just key comparison"
17 and style =
18 flag "style"
19- (optional_with_default ListStyle.Fixed
20+ (optional_with_default
21+ (ListStyle.of_string (value_as_string (get load Key.ListStyle)))
22 (Arg_type.create ListStyle.of_string))
23 ~doc:"list style [fixed | wide | simple]"
24 in
25 diff --git a/lib/config.ml b/lib/config.ml
26index b29a320..ea3e5d7 100644
27--- a/lib/config.ml
28+++ b/lib/config.ml
29 @@ -24,13 +24,13 @@ end
30 module Encoding = struct
31 type t = Json | Yaml | Raw
32
33- let to_string = function Json -> "json" | Yaml -> "yaml" | Raw -> "simple"
34+ let to_string = function Json -> "json" | Yaml -> "yaml" | Raw -> "raw"
35
36 let of_string = function
37 | "json" -> Json
38 | "yaml" -> Yaml
39 | "raw" -> Raw
40- | _ -> failwith "unsupported encoding type"
41+ | key -> failwith (sprintf "unsupported encoding type: %s" key)
42 end
43
44 type t = Yaml.value
45 @@ -135,3 +135,4 @@ let load =
46 | `No | `Unknown ->
47 Unix.mkdir_p state_dir;
48 cfg
49+