aboutsummaryrefslogtreecommitdiff
path: root/libexec/recit-todo
blob: 35f30056e966a260f3e3a115988ed91a74d0798b (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
#!/usr/bin/env bash
# Usage: recit todo [-p project-name]
# Summary: Display TODO entries, optionally for one project
set -e

project=""
query_time=""

recfile=$(recit-file)

while getopts "p:" options; do       
                                          
  case "${options}" in                    
    p)                                    
      project=${OPTARG}                      
      ;;
    :)                                    
      echo "Error: -${OPTARG} requires an argument."
      exit 1
      ;;
    *)                   
      exit 1
      ;;
  esac
done

expression=""

if ! [[ "$project" = "" ]]; then
  if recsel -t Project -p Id ${recfile} | grep "$project" > /dev/null; then
    expression="ProjectRef = '$project'"
  else
    echo "$project not found, list of available projects:"
    recit-recsel-projects
    exit 1
  fi
fi


recit-recsel-entries "$expression" | grep '[0-9][0-9][0-9][0-9]-[0-9][0-9]\|TODO' 

# recfile=$(recit-file)
# if [[ "$expression" = "" ]]; then
#   out=$(recsel -t Entry "$recfile" | recfmt -f "$_RECIT_ROOT/share/recit/templates/custom_delim.templ")
# else
#   out=$(recsel -t Entry "$recfile" -e "$expression" | recfmt -f "$_RECIT_ROOT/share/recit/templates/custom_delim.templ")
# fi
# echo -e "$out"