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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# shellcheck disable=SC2006
GOPT=$(getopt -o hvplr:a:e:d:s: --long help,version,list,plain,userconf,showconf,sync,restore:,backup:,add:,edit:,delete:,show: -n 'bash-notes' -- "$@")
# shellcheck disable=SC2181
if [ $? != 0 ] ; then helptext >&2 ; exit 1 ; fi
# Note the quotes around `$GOPT': they are essential!
eval set -- "$GOPT"
unset GOPT
while true; do
case "$1" in
-h | --help )
helptext
exit
;;
-v | --version )
echo $BASENAME v${VERSION}
exit
;;
-p | --plain )
PLAIN=true
shift
;;
-l | --list )
listnotes
exit
;;
-a | --add )
shift 2
addnote "$TITLE"
exit
;;
-e | --edit )
shift 2
editnote "$NOTE"
exit
;;
-d | --delete )
shift 2
rmnote "$NOTE"
exit
;;
-s | --show )
shift 2
shownote "$NOTE"
exit
;;
-r | --restore )
shift 2
backup_restore $RDIR
exit
;;
--sync )
# I'm forcing it because if you run it manually, chances are that you need to.
gitsync -f
shift
exit
;;
--userconf )
export_config
# shellcheck disable=SC2317
echo "config exported to \"$RCFILE\""
# shellcheck disable=SC2317
exit
;;
--showconf )
configtext
exit
;;
--backup )
shift 2
backup_data $BDIR
exit
;;
-- )
shift
break
;;
* )
break
;;
esac
done
for arg; do
if [ $(check_noteID $arg) ]; then
shownote $arg
else
helptext
exit
fi
done
|