Commit
+15 -9 +/-1 browse
1 | diff --git a/lib/cmd.ml b/lib/cmd.ml |
2 | index f98e5ef..1634953 100644 |
3 | --- a/lib/cmd.ml |
4 | +++ b/lib/cmd.ml |
5 | @@ -29,6 +29,14 @@ let encoding_argument = |
6 | | "Raw" | "raw" | "RAW" -> Raw |
7 | | _ -> failwith "unsupported encoding type") |
8 | |
9 | + let style_argument = |
10 | + Command.Arg_type.create (fun encoding_str -> |
11 | + match encoding_str with |
12 | + | "Fixed" | "fixed" | "FIXED" -> Note.Display.Fixed |
13 | + | "Wide" | "wide" | "WIDE" -> Note.Display.Wide |
14 | + | "Simple" | "simple" | "SIMPLE" -> Note.Display.Simple |
15 | + | _ -> failwith "unsupported style type") |
16 | + |
17 | let filter_arg = |
18 | Command.Arg_type.create |
19 | ~complete:(fun _ ~part -> |
20 | @@ -59,12 +67,9 @@ let encode_value value = function |
21 | | Config config -> Config.to_string config |
22 | | Note note -> Note.to_string note ) |
23 | | Raw -> ( |
24 | - match value with |
25 | - | Config config -> Config.to_string config |
26 | - | Note note -> |
27 | - (In_channel.read_all (Note.get_path note)) |
28 | - |
29 | - ) |
30 | + match value with |
31 | + | Config config -> Config.to_string config |
32 | + | Note note -> In_channel.read_all (Note.get_path note) ) |
33 | |
34 | (* |
35 | * commands |
36 | @@ -265,12 +270,13 @@ note ls |
37 | and fulltext = |
38 | flag "fulltext" no_arg |
39 | ~doc:"perform a fulltext search instead of just key comparison" |
40 | - and simple = |
41 | - flag "simple" no_arg ~doc:"simple program output (machine readable)" |
42 | + and style = |
43 | + flag "style" |
44 | + (optional_with_default Note.Display.Fixed style_argument) |
45 | + ~doc:"list style [fixed | wide | simple]" |
46 | in |
47 | fun () -> |
48 | let open Note.Filter in |
49 | - let style = if simple then Simple else Fixed in |
50 | let filter_kind = if fulltext then Some Fulltext else None in |
51 | let notes = |
52 | Note.Filter.find_many ?strategy:filter_kind ~args:filter_args |