Newer
Older
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
#!/bin/bash -e
pushd `dirname $0` >& /dev/null
mydir=`pwd -P`
popd >& /dev/null
curr_dir=`pwd`
function checkForGem(){
if ! hash gem /dev/null 2>&1; then
echo "Ruby on rail not installed!"
return 1
fi
if ! gem spec codelog > /dev/null 2>&1; then
echo "Gem codelog is not installed-> install it"
if ! gem install codelog > /dev/null 2>&1; then
echo "Error installing codelog"
return 1
fi
fi
return 0
}
function addNewEntry() {
if [ checkForGem ]; then
#we can proceed
read -p "Start creation of changelog entry $1? " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
else
exec codelog new -i $1
fi
else
return 1
fi
}
while getopts sha: opt; do
case $opt in
s)
checkForGem
;;
a) addNewEntry $OPTARG
;;
h)
echo -e "Usage is $0 -s \n-s setup environment for changelog management\n-a add a new entry in changelog"