summaryrefslogtreecommitdiffstats
path: root/tester/covoar/mkExplanation
blob: 6aa7940a39cf4234b297300253ad8f22b031ea65 (plain) (blame)
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
69
70
#! /bin/sh
#
#  Script to help generate an explanation for the covoar explanations file.
#

toggle()
{
  case $1 in
    no)  echo "yes" ;;
    yes) echo "no" ;;
    *)   fatal "Unknown value to toggle ($1)" ;;
  esac
}

usage()
{
  echo "$progname -r sourceLine -c category [-m message|-M msgfile] "
  exit 1
}

message=
messageFile=
category=
sourceLine=
verbose=no
while getopts c:m:M:r:v OPT
do
  case "$OPT" in 
    c) category=$OPTARG ;; 
    m) message=$OPTARG ;; 
    M) messageFile=$OPTARG ;; 
    r) sourceLine=$OPTARG ;; 
    v) verbose=`toggle ${verbose}` ;;
    *) usage ;;
  esac
done

# Error check
if [ "X${sourceLine}" = "X" ] ; then
  echo No sourceLine provided
  usage
fi

let $((shiftcount = $OPTIND - 1))
shift #shiftcount

args=$*

if [ "X${category}" = "X" ] ; then
  echo No category provided
  usage
fi

if [ "X${message}" = "X" -a "X${messageFile}" = "X" ] ; then
  echo No message provided
  usage
fi

# Generate the explanation
echo ${sourceLine}
echo ${category}
if [ "X${message}" = "X" ] ; then
  cat ${messageFile}
else
  echo ${message} | xargs -s 76
fi
echo "+++"
echo

exit 0