-
Notifications
You must be signed in to change notification settings - Fork 1
/
simplefaq.sh
executable file
·78 lines (63 loc) · 1.4 KB
/
simplefaq.sh
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
71
72
73
74
75
#!/bin/bash
help() {
echo -e "
\e[32m fq help - this view
fq dir DIR - set services dir
fq SERVICE - view service faq
fq SERVICE new - open new service on vim
fq SERVICE edit - open existing service on vim
fq SERVICE rm - remove service if exists
fq ls - list service files
---
services dir: $SERVICESDIR
\e[0m"
}
lsservices() {
echo -e '\e[96m
Available services:'
ls $SERVICESDIR
echo -e '\e[0m'
}
clear
if [ "$SERVICESDIR" == "" ]; then
export SERVICESDIR=$(pwd)/services_example
fi
if [ "$1" == "help" ] || [ "$1" == "" ]; then
help
return
elif [ "$1" == "ls" ]; then
lsservices
return
elif [ "$1" == "dir" ]; then
if [ "$2" != "" ]; then
export SERVICESDIR=$2
lsservices
return
else
echo -e "\n\e[31mPlease define a valid path. \e[0m
"
return
fi
fi
echo -e '\e[32m'
if [ -e $SERVICESDIR/$1 ];
then
if [ "$2" == "edit" ]; then
vi $SERVICESDIR/$1
elif [ "$2" == "new" ]; then
echo -e "\n\e[31mService already on faq! \nEdit service with 'faq serviceName edit' \e[0m"
elif [ "$2" == "rm" ]; then
rm $SERVICESDIR/$1
else
cat $SERVICESDIR/$1
fi
lsservices
else
if [ "$2" == "new" ]; then
vi $SERVICESDIR/$1
else
echo -e "\n\e[31mService not found on faq! \nCreate new service with 'faq serviceName new' \e[0m"
fi
lsservices
fi
echo -e '\e[0m'