Skip to content

Commit d9b5f84

Browse files
committed
Update to version 0.0.6
1 parent 7962a36 commit d9b5f84

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

sushiro

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#!/usr/bin/env bash
22
#
3-
# sushiro 0.0.5
3+
# sushiro 0.0.6
44
# (C) 2018 redpeacock78
55
# GPLv3 is applied to this script
66

77
######################################
88
#Randomly display the menu of Sushiro.
99
#Grobals:
10-
# LINES
1110
# CACHE
1211
#Arguments:
1312
# -h
@@ -23,33 +22,30 @@
2322

2423
###USAGE###
2524
[[ "${1}" = "-h" ]] && \
26-
printf "sushiro version 0.0.5\n\nUSAGE: sushiro [OPTIONS] [ANYTHING]\nOptions:\n -l [NUMBER]\n Randomly display the number of specified menus\n (By default it display one item)\n -p [MENU_NAME]\n Display price of menu corresponding to name\n (If not specified,all menus and prices will be displayed)\n -k [MENU_NAME]\n Display the calorie of the name corresponding menu\n (If not specified,all menus and calories are displayed)\n -a\n Display names of all menus(158 species in total)\n -f\n Fetch menus from www.akindo-sushiro.co.jp\n (The menu will be saved in /usr/local/share/sushiro_cache)\n *In case of linuxbrew it is 'directory where linuxbrew is installed/share/sushiro_cache'.*\n" && \
25+
printf "sushiro version 0.0.6\n\nUSAGE: sushiro [OPTIONS] [ANYTHING]\nOptions:\n -l [NUMBER]\n Randomly display the number of specified menus\n (By default it display one item)\n -p [MENU_NAME]\n Display price of menu corresponding to name\n (If not specified,all menus and prices will be displayed)\n -k [MENU_NAME]\n Display the calorie of the name corresponding menu\n (If not specified,all menus and calories are displayed)\n -a\n Display names of all menus(158 species in total)\n -f\n Fetch menus from www.akindo-sushiro.co.jp\n (The menu will be saved in /usr/local/share/sushiro_cache)\n *In case of linuxbrew it is 'directory where linuxbrew is installed/share/sushiro_cache'.*\n" && \
2726
exit 0
2827

2928

3029
###DEFAULT_PARAMETER###
31-
LINES=1
30+
#LINES=1
3231

3332
###FETCH###
3433
#CACHE="/usr/local/share/sushiro_cache"
3534
CACHE=$(dirname "${0}" | sed 's#bin#share/sushiro_cache#')
3635

37-
[[ "${1}" = "-f" ]] && \
38-
curl -s 'https://www.akindo-sushiro.co.jp/menu/' -o "$CACHE" &&\
39-
exit 0
40-
[[ ! -f "$CACHE" ]] && \
41-
curl -s 'https://www.akindo-sushiro.co.jp/menu/' -o "$CACHE"
36+
#[[ "${1}" = "-f" ]] && \
37+
# curl -s 'https://www.akindo-sushiro.co.jp/menu/' -o "$CACHE" &&\
38+
#exit 0
39+
[[ ! -f "${CACHE}" ]] && \
40+
curl -s 'https://www.akindo-sushiro.co.jp/menu/' -o "${CACHE}"
4241

4342
###TEXT###
4443
while [[ "${#}" -gt 0 ]]; do
4544
##RONDOM_MENUS##
4645
if [[ "${1}" = "-l" ]]; then
4746
shift && \
48-
lines="$(tr -dc '0-9' <<< $1)"
49-
if [[ "${lines}" -eq 0 ]]; then
50-
lines="${LINES}"
51-
fi
52-
cat $CACHE \
47+
LINES="${1:-1}"
48+
cat "${CACHE}" \
5349
| grep -e '="ttl"' -e price \
5450
| sed 's/<[^>]*>//g;s/ + /+/g;s/場合 /場合/g;/^$/d' \
5551
| tr '\n' ' ' \
@@ -61,14 +57,14 @@ while [[ "${#}" -gt 0 ]]; do
6157
| awk -F ',' '{print $1}' \
6258
| sort -R \
6359
| grep "\S" \
64-
| shuf -n "${lines}" && \
60+
| shuf -n "${LINES}" && \
6561
exit 0
6662
##MENUS_PRICES##
6763
elif [[ "${1}" = "-p" ]]; then
6864
shift && \
69-
PRICES="$1"
65+
PRICES="${1}"
7066
shift
71-
cat $CACHE \
67+
cat "${CACHE}" \
7268
| grep -e '="ttl"' -e price \
7369
| sed 's/<[^>]*>//g;s/ + /+/g;s/場合 /場合/g;/^$/d' \
7470
| tr '\n' ' ' \
@@ -85,9 +81,9 @@ while [[ "${#}" -gt 0 ]]; do
8581
##MENUS_CALORIES##
8682
elif [[ "${1}" = "-k" ]]; then
8783
shift && \
88-
CALORIES="$1"
84+
CALORIES="${1}"
8985
shift
90-
cat $CACHE \
86+
cat "${CACHE}" \
9187
| grep -e '="ttl"' -e price \
9288
| sed 's/<[^>]*>//g;s/ + /+/g;s/場合 /場合/g;/^$/d' \
9389
| tr '\n' ' ' \
@@ -103,7 +99,7 @@ while [[ "${#}" -gt 0 ]]; do
10399
exit 0
104100
##SHOW_ALL_MENUS##
105101
elif [[ "${1}" = "-a" ]]; then
106-
cat $CACHE \
102+
cat "${CACHE}" \
107103
| grep -e '="ttl"' -e price \
108104
| sed 's/<[^>]*>//g;s/ + /+/g;s/場合 /場合/g;/^$/d' \
109105
| tr '\n' ' ' \
@@ -115,6 +111,10 @@ while [[ "${#}" -gt 0 ]]; do
115111
| awk -F, 'NR>1{print $1}' \
116112
| grep "\S" && \
117113
exit 0
114+
##FETCH##
115+
elif [[ "${1}" = "-f" ]]; then
116+
curl -s 'https://www.akindo-sushiro.co.jp/menu/' -o "${CACHE}" && \
117+
exit 0
118118
else
119119
printf "sushiro: missing operand\nTry 'sushiro -h' for more information.\n" && \
120120
exit 2

0 commit comments

Comments
 (0)