stitch

Note taking for messy minimalists

git clone git://mccd.space/stitch
commit a9b8ac50daf0cd28034c310dc1cda07ba9a2fc0c
parent e57d29c39da80f9ef9cb68a9322ad2c4254f2d80
Author: Marc Coquand <marc@mccd.space>
Date:   Thu, 16 May 2024 09:29:19 -0500

Document environment variables

Diffstat:
Mbin/main.ml | 53++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mlib/done.ml | 2+-
Mlib/help_screen.ml | 4++--
Mlib/todos.ml | 2+-
4 files changed, 56 insertions(+), 5 deletions(-)
diff --git a/bin/main.ml b/bin/main.ml
@@ -7,10 +7,61 @@ let tag_arg =
 
 let headlines_t = Term.(const Stitch.start $ tag_arg $ const ())
 
+let envs =
+  let docs = "ENVIRONMENT VARIABLES" 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 = "Show titles in a condensed list" in
   let man = [ `S Manpage.s_bugs; `P "Email bug reports to marc@mccd.space" ] in
-  let info = Cmd.info "headlines" ~version:"0.1" ~doc ~man in
+  let info = Cmd.info ~envs "headlines" ~version:"0.1" ~doc ~man in
   Cmd.v info headlines_t
 
 
diff --git a/lib/done.ml b/lib/done.ml
@@ -113,7 +113,7 @@ let rec render
       }
   | `Key (`ASCII 'j', []) | `Key (`ASCII 'N', [ `Ctrl ]) -> scroll_down ()
   | `Key (`ASCII 'k', []) | `Key (`ASCII 'P', [ `Ctrl ]) -> scroll_up ()
-  | `Key (`ASCII 't', []) ->
+  | `Key (`ASCII 'T', [ `Ctrl ]) ->
     let selected_file, _ = Array.get content (y - content_start) in
     let _ = Grep.toggle_todo selected_file in
     let content, content_pretty = load_done () in
diff --git a/lib/help_screen.ml b/lib/help_screen.ml
@@ -52,8 +52,8 @@ let render_menu ~menu ~title ~start_y =
 
 
 let note_view_menu = [ "Toggle Stitch", "s" ]
-let todo_view_menu = [ "Toggle Done", "t"; "Refresh", "g" ]
-let done_view_menu = [ "Toggle Todo", "t"; "Refresh", "g" ]
+let todo_view_menu = [ "Toggle Done", "Ctrl-t"; "Refresh", "g" ]
+let done_view_menu = [ "Toggle Todo", "Ctrl-t"; "Refresh", "g" ]
 
 let rec render t ({ go_back } as state) =
   let img =
diff --git a/lib/todos.ml b/lib/todos.ml
@@ -113,7 +113,7 @@ let rec render
     Input_prompt.render t input_state
   | `Key (`ASCII 'j', []) | `Key (`ASCII 'N', [ `Ctrl ]) -> scroll_down ()
   | `Key (`ASCII 'k', []) | `Key (`ASCII 'P', [ `Ctrl ]) -> scroll_up ()
-  | `Key (`ASCII 't', []) ->
+  | `Key (`ASCII 'T', [ `Ctrl ]) ->
     let selected_file, _ = Array.get content (y - content_start) in
     let _ = Grep.toggle_done selected_file in
     let content, content_pretty = load_todos () in