aboutsummaryrefslogtreecommitdiff
path: root/libexec/recit-entries
blob: 343006d0204a2278a6f08d36f590e029f130e63f (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
#!/usr/bin/env bash
# Usage: recit entries [-p project-name]

# shellcheck source=/dev/null
source lib/loader

recfile=$(load_recit)

project=""

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

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