Skip to content

Commit

Permalink
parse_long_opts function
Browse files Browse the repository at this point in the history
  • Loading branch information
Euro committed Mar 7, 2021
1 parent 471db09 commit a6a831a
Showing 1 changed file with 51 additions and 51 deletions.
102 changes: 51 additions & 51 deletions ytfzf
Original file line number Diff line number Diff line change
Expand Up @@ -628,74 +628,76 @@ update_ytfzf () {
#is used to know whether or not scraping the search page is necessary
scrape=1
#OPT
parse_opt () {
#the first arg is the option
opt=$1
#second arg is the optarg
OPTARG="$2"
case ${opt} in
#Long options
-)
#if the option has a short version it calls this function with the opt as the shortopt
case "${OPTARG}" in
help) parse_opt "h" ;;
parse_long_opt () {
opt="$1"
#if the option has a short version it calls this function with the opt as the shortopt
case "${opt}" in
help) parse_opt "h" ;;

ext-menu) parse_opt "D" ;;
ext-menu) parse_opt "D" ;;

download) parse_opt "d" ;;
download) parse_opt "d" ;;

choose-from-history) parse_opt "H" ;;
choose-from-history) parse_opt "H" ;;

clear-history) parse_opt "x" ;;
clear-history) parse_opt "x" ;;

random-select) parase_opt "r" ;;
search) parse_opt "s" ;;
random-select) parase_opt "r" ;;
search) parse_opt "s" ;;


loop) parse_opt "l" ;;
loop) parse_opt "l" ;;

thumbnails) parse_opt "t" ;;
thumbnails) parse_opt "t" ;;

link-only) parse_opt "L" ;;
link-only) parse_opt "L" ;;

video-count=*) parse_opt "n" "${OPTARG#*=}" ;;
video-count=*) parse_opt "n" "${opt#*=}" ;;

audio-only) parse_opt "m" ;;
audio-only) parse_opt "m" ;;

auto-play) parse_opt "a" ;;
auto-play) parse_opt "a" ;;

random-auto-play) parse_opt "r" ;;
random-auto-play) parse_opt "r" ;;

upload-time=*) upload_date_filter="${OPTARG#*=}" ;;
last-hour) upload_date_filter="last-hour" ;;
today) upload_date_filter="today" ;;
this-week) upload_date_filter="this-week" ;;
this-month) upload_date_filter="this-month" ;;
this-year) upload_date_filter="this-year" ;;
upload-time=*) upload_date_filter="${opt#*=}" ;;
last-hour) upload_date_filter="last-hour" ;;
today) upload_date_filter="today" ;;
this-week) upload_date_filter="this-week" ;;
this-month) upload_date_filter="this-month" ;;
this-year) upload_date_filter="this-year" ;;

upload-sort=*) sort_by_filter="${OPTARG#*=}" ;;
upload-date) sort_by_filter="upload-date" ;;
view-count) sort_by_filter="view-count" ;;
rating) sort_by_filter="rating" ;;
upload-sort=*) sort_by_filter="${opt#*=}" ;;
upload-date) sort_by_filter="upload-date" ;;
view-count) sort_by_filter="view-count" ;;
rating) sort_by_filter="rating" ;;

filter-id=*|sp=*) sp="${OPTARG#*=}" ;;
filter-id=*|sp=*) sp="${opt#*=}" ;;


previews=*) export PREVIEW_SIDE="${OPTARG#*=}" ;;
previews=*) export PREVIEW_SIDE="${opt#*=}" ;;

update) update_ytfzf ;;
update) update_ytfzf ;;

version)
printf "ytfzf: $YTFZF_VERSION\n"
printf "youtube-dl: $(youtube-dl --version)\n"
exit;
;;
version)
printf "ytfzf: $YTFZF_VERSION\n"
printf "youtube-dl: $(youtube-dl --version)\n"
exit ;;

*)
printf "Illegal option --$OPTARG\n"
usageinfo
exit 2 ;;
esac ;;
*)
printf "Illegal option --$opt\n"
usageinfo
exit 2 ;;
esac
}
parse_opt () {
#the first arg is the option
opt="$1"
#second arg is the optarg
OPTARG="$2"
case ${opt} in
#Long options
-) parse_long_opt "$OPTARG" ;;
#Short options
h) helpinfo
exit ;;
Expand Down Expand Up @@ -724,8 +726,7 @@ parse_opt () {
t) show_thumbnails=1 ;;

v) printf "ytfzf: $YTFZF_VERSION\n"
exit;
;;
exit ;;

L) show_link_only=1 ;;

Expand Down Expand Up @@ -755,8 +756,7 @@ if [ ! -t 0 ]; then
done
fi
[ -n "$search_query" ] && is_stdin=1 || is_stdin=0
search_query="${search_query-$*}"
check_if_url "$search_query"
check_if_url "${search_query:=$*}"
# If in auto select mode don't download thumbnails
[ $auto_select -eq 1 -o $random_select -eq 1 ] && show_thumbnails=0;

Expand Down

0 comments on commit a6a831a

Please sign in to comment.