-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathu.sh
68 lines (62 loc) · 1.12 KB
/
u.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
#!/bin/bash
FILENAME="u.yaml"
# Parse arguments
usage() {
echo "Usage: $0 [-h] [-v] [-s SHORTCUT -u URL] [-l] [-r SHORTCUT]"
echo " -h Help. Display this message and quit."
echo " -v Version. Print version number and quit."
echo " -s Shortcut -u URL"
echo " -l Show all shortcuts"
echo " -r Specify a shortcut to removed"
exit
}
list() {
# list all
exit
}
version() {
# version
exit
}
shortcut=
url=
remove=
while getopts ":hvls:u:r:" opt; do
case $opt in
h)
usage
;;
v)
version
;;
s)
shortcut=$OPTARG
;;
u)
url=$OPTARG
;;
l)
list
;;
r)
remove=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
if [[ -n "$shortcut" ]] && [[ -n "$url" ]]; then
echo $shortcut $url
elif [[ -n "$shortcut" ]] || [[ -n "$url" ]]; then
echo "-s and -u must be used together"
elif [[ -n "$remove" ]]; then
echo $remove
elif [[ -n "$1" ]]; then
echo $1
fi