-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeed
More file actions
executable file
·67 lines (53 loc) · 1.09 KB
/
feed
File metadata and controls
executable file
·67 lines (53 loc) · 1.09 KB
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
#!/bin/bash
temp=$(getopt --name 'feed' --options 'bh' --long 'bookmark,help' -- "$@")
eval set -- "$temp"
unset temp
main() {
options=()
args=()
parse_options $@
local command="${args[0]}"
unset args[0]
case "$command" in
*)
newsboat;;
esac
}
bookmark() {
local url="$1"
local title="$2"
local description="$3"
local feed_title="$4"
local dir="$HOME/documents/feeds"
local file=$(echo "$dir/$feed_title.txt" | sed 's/ /_/g')
[ ! -e "$dir" ] && mkdir -p "$dir"
[ ! -e "$file" ] && echo -e "Title|URL|Notes\n-$feed_title-" > "$file"
echo -e "${title}|${url}|${description}" >> "$file"
exit
}
help() {
echo 'Help Menu'
exit 0
}
parse_options() {
while [ -n "$1" ]; do
case "$1" in
'-b'|'--bookmark')
args+=(bookmark)
shift && continue;;
'-h'|'--help')
help
break;;
'--')
shift
break;;
*)
echo 'Internal error!' >&2
exit 1;;
esac
done
for arg; do
args+=("$arg")
done
}
main "$@"