stitch
Note taking for messy minimalists
git clone git://mccd.space/stitch| Log | Files | Refs | README | LICENSE | Mail |
main.ml (6458B)
1 open Cmdliner
2
3 let tag_arg =
4 let doc = "Search entries for a given tag." in
5 Arg.(value & opt string "" & info [ "t"; "tag" ] ~docv:"TAG" ~doc)
6
7
8 let headlines_t = Term.(const Stitch.start $ tag_arg $ const ())
9
10 let envs =
11 let docs = Cmdliner.Manpage.s_environment in
12 [ Cmd.Env.info
13 ~docs
14 ~doc:
15 "Directory where Stitch should search for notes. Needs to be set in order for \
16 the program to work. Must be absolute path, I.E /home/bob/notes"
17 "STITCH_DIRECTORY"
18 ; Cmd.Env.info
19 ~docs
20 ~doc:
21 "Grep command to use (defaults to \"grep\"). Stitch also works well with ugrep, \
22 which greatly speeds up the program."
23 "STITCH_GREP_CMD"
24 ; Cmd.Env.info
25 ~docs
26 ~doc:"Pattern to use for headlines. (Default \"* \")"
27 "STITCH_HEADLINE_PATTERN"
28 ; Cmd.Env.info
29 ~docs
30 ~doc:
31 "Pattern to use by grep to fetch headlines. Needs to be double escaped for \
32 OCaml. (Default \"^\\\\* \")"
33 "STITCH_HEADLINE_PATTERN_REGEXP"
34 ; Cmd.Env.info
35 ~docs
36 ~doc:"Pattern used by grep to find tags. (Default \":[a-z-]+:\", matches :a-tag:)"
37 "STITCH_TAG_PATTERN"
38 ; Cmd.Env.info
39 ~docs
40 ~doc:"Pattern for TODOS. Used for substitution. (Default \"* TODO\")"
41 "STITCH_TODO"
42 ; Cmd.Env.info
43 ~docs
44 ~doc:
45 "Regexp used by grep to find TODO items. Needs to be double escaped for OCaml. \
46 (Default \"^\\\\* TODO\")"
47 "STITCH_TODO_REGEXP"
48 ; Cmd.Env.info
49 ~docs
50 ~doc:"Pattern for DONE items. Used for substitution. (Default \"* DONE\")"
51 "STITCH_DONE"
52 ; Cmd.Env.info
53 ~docs
54 ~doc:
55 "Regexp used by grep to find DONE items. Needs to be double escaped for OCaml. \
56 (Default \"^\\\\* DONE\")"
57 "STITCH_DONE_REGEXP"
58 ]
59
60
61 let headlines_cmd =
62 let doc = "note managing for unorganized minimalists" in
63 let author = [ `S Manpage.s_authors; `P "Marc Coquand (mccd.space)" ] in
64 let bugs =
65 [ `S Manpage.s_bugs; `P "Email bug reports to ~marcc/stitch-general@lists.sr.ht." ]
66 in
67 let description =
68 [ `S Manpage.s_description
69 ; `P
70 "Stitch is a minimal note and todo composing tool inspired by Howm for Emacs. It \
71 works with any CLI editor and file format."
72 ; `P
73 "Stitch comes preconfigured to handle an org-esque file format, but can be \
74 reconfigured to handle any file format you want (SEE ENVIRONMENT). "
75 ; `P
76 "To set up, you will need to set STITCH_DIRECTORY (SEE ENVIRONMENT) at minimum. \
77 Stitch does not come with any built-in note-capturing tool, but you can easily \
78 set one up on your own (SEE EXAMPLES)."
79 ; `P "Stitch currently only works with a system where you have one file per note."
80 ; `P
81 "When you enter the program for the first time, press '?' to see the list of \
82 keybindings."
83 ]
84 in
85 let example_set_up_basic =
86 [ `S Manpage.s_examples
87 ; `P "To get started, start by setting up a note directory in your shell profile"
88 ; `Pre "export STITCH_DIRECTORY=/home/bob/notes"
89 ; `P
90 "Stitch does not specify anything on how to capture your notes, but you can \
91 install the following shell script to your \\$PATH to have a basic note \
92 capturing system."
93 ; `Pre
94 " #!/bin/sh\n\
95 \ JRNL=\"\\$STITCH_DIRECTORY/\\$(date +'%y-%m-%d.%H:%M.%S').org\"\n\
96 \ echo '* ' > /tmp/capture \n\
97 \ \\$EDITOR /tmp/capture +1\n\
98 \ if grep -q '^\\\\*\\\\s*\\$' /tmp/capture \n\
99 \ then \n\
100 \ echo \"Empty capture; ignoring\"\n\
101 \ else \n\
102 \ echo \"Storing capture in \\$JRNL\"\n\
103 \ cat /tmp/capture > \\$JRNL\n\
104 \ fi"
105 ; `P
106 "Now you can run capture in your terminal and it will prompt you to write your \
107 note and store it in your notes with a timestamp. You can also capture within \
108 stitch, by running !capture"
109 ; `P
110 "With that, you can begin to capture your notes and they will be displayed in \
111 reverse chronological order in stitch. You can add tags, for example :journal: \
112 and :work:."
113 ; `P
114 "Once added, you can start viewing your notes in Stitch. So if you added a few \
115 journal notes, you can view them with"
116 ; `Pre "stitch -t :journal:"
117 ; `P
118 "If you press f, you will see toggle to see all notes stitched together. You can \
119 see all commands with '?'"
120 ; `P "You can also launch stitch without arguments to see all."
121 ; `P
122 "To set up TODO capturing, you can add a command shell script todo to your PATH \
123 to capture TODO items"
124 ; `Pre
125 " #!/bin/sh\n\
126 \ TODO_BASE='* TODO '\n\
127 \ JRNL=\"\\$STITCH_DIRECTORY/\\$(date +'%y-%m-%d.%H:%M.%S').org\"\n\
128 \ echo '* TODO ' > /tmp/capture\n\
129 \ \\$EDITOR /tmp/capture +1\"\n\
130 \ if grep -q '^\\\\* TODO\\\\s*\\$' /tmp/capture \n\
131 \ then \n\
132 \ echo \"Empty capture\"\n\
133 \ else \n\
134 \ echo \"Storing capture in \\$JRNL\"\n\
135 \ cat /tmp/capture > \\$JRNL\n\
136 \ fi"
137 ; `P
138 "After that, you can capture a few TODO items by running todo in your terminal \
139 or !todo in stitch, and you will be able to view them if you press 2. You can \
140 see done items if you press 3. Press '?' to see how to toggle the todo items."
141 ; `P
142 "You can also delete notes by selecting the line of the note you want to delete \
143 and then execute !rm %(file)"
144 ]
145 in
146 let commands =
147 [ `S "COMMAND SUBSTITUTION"
148 ; `P ""
149 ; `P
150 "You can run arbitrary shell commands in Stitch. These commands can make use of \
151 the variable substitutions below."
152 ; `I ("%(file)", "Currently selected file")
153 ; `I ("%(line)", "Currently selected content")
154 ; `P
155 "For example, if you select a line and run !rm %(file), it will remove that file."
156 ]
157 in
158 let credit =
159 [ `S "CREDIT"
160 ; `P "Stitch was inspired by the note-taking tool Howm for EMacs by HIRAOKA Kazuyuki."
161 ]
162 in
163 let info =
164 Cmd.info
165 ~envs
166 "stitch"
167 ~version:"0.0.10 ALPHA"
168 ~doc
169 ~man:
170 (List.concat
171 [ description; commands; example_set_up_basic; bugs; author; credit ])
172 in
173 Cmd.v info headlines_t
174
175
176 let () = exit (Cmd.eval headlines_cmd)