Quick fix

This commit is contained in:
inigoortega 2019-09-02 16:47:30 +02:00
parent 9d8aac2576
commit ef5ce0edaa
1 changed files with 19 additions and 6 deletions

View File

@ -27,11 +27,15 @@ usage() {
-i Reads from standard input instead of clipboard
-p Read from primary selection instead of clipboard
-b <browser> Sets the browser to use when openning op.gg
If not provided, uses \$BROWSER or the default browser instead.
-r <region> Sets the region (server) to search summoners on
-s <summoner name> Use provided summoner names as yours
If not provided, uses \$LOL_REGION instead.
-s <summoner name> Use provided summoner names as yours. Delimitate each
summoner name with ':', such as, \"hi im gosu:hide on bush:brian\"
If not provided, uses \$LOL_SUMMONERS instead.
Made for r/leagueoflinux by Iñigo Ortega
"
" >&2
exit 1
}
@ -104,15 +108,24 @@ fi
# Get the text copied from champion select
if [ -z "$stdin" ]; then
text="$(xclip -o -selection ${selection:-clipboard})"
if [ $(command -v xclip) ]; then
text="$(xclip -o -selection ${selection:-clipboard})"
else
echo "xclip not found!" 1>&2
exit 4
fi
else
text="$(cat -)"
fi
# A simple check before reading the text
if [ "$(echo "$text" | wc -l)" -lt 3 ]; then
echo "Are you sure this is correct?\n" 1>&2
echo "$text"
fi
# Get summoner names and save them into the temporary file
# "tee" used in the end, for debugging porpuses, just in case someone doesn't
# know how to use Ctrl+c
echo "$text" | grep "$pattern" | sed -E "s/(.*)$pattern/\1/" | tee "$temp"
echo "$text" | grep "$pattern" | sed -E "s/(.*)$pattern/\1/" > "$temp"
# Region
if [ -z "$region" ]; then