aboutsummaryrefslogtreecommitdiff
path: root/bin/main.ml
blob: cda58ca08bc99aef70d86402121b4a5bf9d74ae3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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 = "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 ~envs "headlines" ~version:"0.1" ~doc ~man in
  Cmd.v info headlines_t


let () = exit (Cmd.eval headlines_cmd)