Merge pull request #1 from duckunix/master
Switched to getopt from getopts, added usage, added long arguments
This commit is contained in:
commit
1532849183
38
styli.sh
38
styli.sh
@ -40,18 +40,36 @@ reddit(){
|
|||||||
wget -T $timeout -U "$useragent" --no-check-certificate -q -P down -O "wallpaper.jpg" $target_url &>/dev/null
|
wget -T $timeout -U "$useragent" --no-check-certificate -q -P down -O "wallpaper.jpg" $target_url &>/dev/null
|
||||||
|
|
||||||
}
|
}
|
||||||
|
usage(){
|
||||||
|
echo "Usage: styli.sh [-s | --search <string>]
|
||||||
|
[-h | --hight <hight>]
|
||||||
|
[-w | --width <width>]
|
||||||
|
[-b | --fehbg <feh bg opt>]
|
||||||
|
[-c | --fehopt <feh opt>]
|
||||||
|
[-r | --subreddit <subreddit>]
|
||||||
|
[-l | --link <link>]
|
||||||
|
[-p | --termcolor]"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
pywal=0
|
pywal=0
|
||||||
while getopts h:w:s:l:b:r:c:p flag
|
PARSED_ARGUMENTS=$(getopt -a -n $0 -o h:w:s:l:b:r:c:p --long search:,hight:,width:,fehbg:,fehopt:,subreddit:,termcolor -- "$@")
|
||||||
|
VALID_ARGUMENTS=$?
|
||||||
|
if [ "$VALID_ARGUMENTS" != "0" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
while :
|
||||||
do
|
do
|
||||||
case "${flag}" in
|
case "${1}" in
|
||||||
b) bgtype=${OPTARG};;
|
-b | --fehbg) bgtype=${2} ; shift 2 ;;
|
||||||
s) search=${OPTARG};;
|
-s | --search) search=${2} ; shift 2 ;;
|
||||||
h) height=${OPTARG};;
|
-h | --height) height=${2} ; shift 2 ;;
|
||||||
w) width=${OPTARG};;
|
-w | --width) width=${2} ; shift 2 ;;
|
||||||
l) link=${OPTARG};;
|
-l | --link) link=${2} ; shift 2 ;;
|
||||||
r) sub=${OPTARG};;
|
-r | --subreddit) sub=${2} ; shift 2 ;;
|
||||||
c) custom=${OPTARG};;
|
-c | --fehopt) custom=${2} ; shift 2 ;;
|
||||||
p) pywal=1;;
|
-p | --termcolor) pywal=1 ; shift ;;
|
||||||
|
-- | '') shift; break ;;
|
||||||
|
*) echo "Unexpected option: $1 - this should not happen." ; usage ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
feh=(feh)
|
feh=(feh)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user