open Cmdliner let tag_arg = let doc = "Search entries for a given tag." in Arg.(value & opt string "" & info [ "t"; "tag" ] ~docv:"TAG" ~doc) let headlines_t = Term.(const Stitch.start $ tag_arg $ const ()) let envs = let docs = Cmdliner.Manpage.s_environment in [ Cmd.Env.info ~docs ~doc: "Directory where Stitch should search for notes. Needs to be set in order for \ the program to work. Must be absolute path, I.E /home/bob/notes" "STITCH_DIRECTORY" ; Cmd.Env.info ~docs ~doc: "Grep command to use (defaults to \"grep\"). Stitch also works well with ugrep, \ which greatly speeds up the program." "STITCH_GREP_CMD" ; Cmd.Env.info ~docs ~doc:"Pattern to use for headlines. (Default \"* \")" "STITCH_HEADLINE_PATTERN" ; Cmd.Env.info ~docs ~doc: "Pattern to use by grep to fetch headlines. Needs to be double escaped for \ OCaml. (Default \"^\\\\* \")" "STITCH_HEADLINE_PATTERN_REGEXP" ; Cmd.Env.info ~docs ~doc:"Pattern used by grep to find tags. (Default \":[a-z-]+:\", matches :a-tag:" "STITCH_TAG_PATTERN" ; Cmd.Env.info ~docs ~doc:"Pattern for TODOS. Used for substitution. (Default \"* TODO\")" "STITCH_TODO" ; Cmd.Env.info ~docs ~doc: "Regexp used by grep to find TODO items. Needs to be double escaped for OCaml. \ (Default \"^\\\\* TODO\")" "STITCH_TODO_REGEXP" ; Cmd.Env.info ~docs ~doc:"Pattern for DONE items. Used for substitution. (Default \"* DONE\")" "STITCH_DONE" ; Cmd.Env.info ~docs ~doc: "Regexp used by grep to find DONE items. Needs to be double escaped for OCaml. \ (Default \"^\\\\* DONE\")" "STITCH_DONE_REGEXP" ] let headlines_cmd = let doc = "note managing for unorganized minimalists" in let author = [ `S Manpage.s_authors; `P "Marc Coquand (mccd.space)" ] in let bugs = [ `S Manpage.s_bugs; `P "Email bug reports to ~marcc/stitch-general@lists.sr.ht." ] in let description = [ `S Manpage.s_description ; `P "Stitch is a minimal note and todo composing tool inspired by Howm for Emacs. It \ works with any CLI editor and file format." ; `P "Stitch comes preconfigured to handle an org-esque file format, but can be \ reconfigured to handle any file format you want (SEE ENVIRONMENT). " ; `P "To set up, you will need to set STITCH_DIRECTORY (SEE ENVIRONMENT) at minimum. \ Stitch does not come with any built-in note-capturing tool, but you can easily \ set one up on your own (SEE EXAMPLES)." ; `P "Stitch currently only works with a system where you have one file per note." ; `P "When you enter the program for the first time, press '?' to see the list of \ keybindings." ] in let example_set_up_basic = [ `S Manpage.s_examples ; `P "To get started, start by setting up a note directory in your shell profile" ; `Pre "export STITCH_DIRECTORY=/home/bob/notes" ; `P "Stitch does not specify anything on how to capture your notes, but you can \ install the following shell script to your \\$PATH to have a basic note \ capturing system." ; `Pre " #!/bin/sh\n\ \ JRNL=\"\\$STITCH_DIRECTORY/\\$(date +'%y-%m-%d.%H:%M.%S').org\"\n\ \ echo '* ' > /tmp/capture \n\ \ \\$EDITOR /tmp/capture +1\n\ \ if grep -q '^\\\\*\\\\s*\\$' /tmp/capture \n\ \ then \n\ \ echo \"Empty capture; ignoring\"\n\ \ else \n\ \ echo \"Storing capture in \\$JRNL\"\n\ \ cat /tmp/capture > \\$JRNL\n\ \ fi" ; `P "Now you can run capture in your terminal and it will prompt you to write your \ note and store it in your notes with a timestamp. You can also capture within \ stitch, by running !capture" ; `P "With that, you can begin to capture your notes and they will be displayed in \ reverse chronological order in stitch. You can add tags, for example :journal: \ and :work:." ; `P "Once added, you can start viewing your notes in Stitch. So if you added a few \ journal notes, you can view them with" ; `Pre "stitch -t :journal:" ; `P "If you press f, you will see toggle to see all notes stitched together. You can \ see all commands with '?'" ; `P "You can also launch stitch without arguments to see all." ; `P "To set up TODO capturing, you can add a command shell script todo to your PATH \ to capture TODO items" ; `Pre " #!/bin/sh\n\ \ TODO_BASE='* TODO '\n\ \ JRNL=\"\\$STITCH_DIRECTORY/\\$(date +'%y-%m-%d.%H:%M.%S').org\"\n\ \ echo '* TODO ' > /tmp/capture\n\ \ \\$EDITOR /tmp/capture +1\"\n\ \ if grep -q '^\\\\* TODO\\\\s*\\$' /tmp/capture \n\ \ then \n\ \ echo \"Empty capture\"\n\ \ else \n\ \ echo \"Storing capture in \\$JRNL\"\n\ \ cat /tmp/capture > \\$JRNL\n\ \ fi" ; `P "After that, you can capture a few TODO items by running todo in your terminal \ or !todo in stitch, and you will be able to view them if you press 2. You can \ see done items if you press 3. Press '?' to see how to toggle the todo items." ; `P "You can also delete notes by selecting the line of the note you want to delete \ and then execute !rm %(file)" ] in let commands = [ `S "COMMAND SUBSTITUTION" ; `P "" ; `P "You can run arbitrary shell commands in Stitch. These commands can make use of \ the variable substitutions below." ; `I ("%(file)", "Currently selected file") ; `I ("%(line)", "Currently selected content") ; `P "For example, if you select a line and run !rm %(file), it will remove that file." ] in let credit = [ `S "CREDIT" ; `P "Stitch was inspired by the note-taking tool Howm for EMacs by HIRAOKA Kazuyuki." ] in let info = Cmd.info ~envs "stitch" ~version:"0.0.3 ALPHA" ~doc ~man: (List.concat [ description; commands; example_set_up_basic; bugs; author; credit ]) in Cmd.v info headlines_t let () = exit (Cmd.eval headlines_cmd)