Author: Kevin Schoon [kevinschoon@gmail.com]
Hash: ce85d2d03f4a8df543fa9be10a2f4aa83c9bfc43
Timestamp: Sun, 25 Apr 2021 19:52:23 +0000 (3 years ago)

+23 -5 +/-1 browse
allow passing title as anonymous arg to most commands
1diff --git a/lib/cmd.ml b/lib/cmd.ml
2index 15cdf75..fec8dd6 100644
3--- a/lib/cmd.ml
4+++ b/lib/cmd.ml
5 @@ -90,6 +90,7 @@ json for consumption by other tools.
6 |})
7 [%map_open
8 let titles, tags, operator = filter_args
9+ and title = anon (sequence ("title" %: search_arg `Title))
10 and encoding =
11 flag "encoding"
12 (optional_with_default cfg.encoding encoding_arg)
13 @@ -98,7 +99,12 @@ json for consumption by other tools.
14 fun () ->
15 let notes =
16 Note.find_many
17- ~term:{ titles; tags; operator = flag_to_op operator }
18+ ~term:
19+ {
20+ titles = List.append title titles;
21+ tags;
22+ operator = flag_to_op operator;
23+ }
24 get_notes
25 in
26 List.iter
27 @@ -163,12 +169,18 @@ let delete_note =
28 Delete the first note that matches the filter criteria.
29 |})
30 [%map_open
31- let titles, tags, operator = filter_args in
32+ let titles, tags, operator = filter_args
33+ and title = anon (sequence ("title" %: search_arg `Title)) in
34 fun () ->
35 let notes = get_notes in
36 let note =
37 Note.find_one
38- ~term:{ titles; tags; operator = flag_to_op operator }
39+ ~term:
40+ {
41+ titles = List.append title titles;
42+ tags;
43+ operator = flag_to_op operator;
44+ }
45 notes
46 in
47 match note with
48 @@ -185,11 +197,17 @@ let edit_note =
49 Select a note that matches the filter criteria and open it in your text editor.
50 |})
51 [%map_open
52- let titles, tags, operator = filter_args in
53+ let titles, tags, operator = filter_args
54+ and title = anon (sequence ("title" %: search_arg `Title)) in
55 fun () ->
56 let note =
57 Note.find_one
58- ~term:{ titles; tags; operator = flag_to_op operator }
59+ ~term:
60+ {
61+ titles = List.append title titles;
62+ tags;
63+ operator = flag_to_op operator;
64+ }
65 get_notes
66 in
67 match note with