replace parser with argparse

This commit is contained in:
lee2sman 2021-12-31 18:03:09 -05:00
parent a0e6c2c7e1
commit d5808ff535
1 changed files with 18 additions and 16 deletions

View File

@ -30,7 +30,7 @@ function usage
echo " -t THEME Set theme for reader format. Default: medium"
echo " Theme options: "
for theme in themes/*.css
echo (string replace -r '\.[^\.]+$' '' (basename $theme))
echo " " (string replace -r '\.[^\.]+$' '' (basename $theme))
end
echo ""
echo " --format FORMAT"
@ -44,24 +44,26 @@ function usage
end
function check_args
for current_arg in (seq 1 (count $argv))
set next_arg $argv[(math $current_arg + 1)]
argparse h/help t/theme= f/format= o/output= -- $argv
or exit 1
switch $argv[$current_arg]
case -h --help
if set -q _flag_help
usage
break
case -t --theme
echo "theme: " $next_arg
set -g theme themes/$next_arg.css
case -f --format
echo "format: " $next_arg
set -g format $next_arg
case -o --output
echo "output: " $next_arg
set -g output $next_arg
end
exit
end
if set -q _flag_t
set theme themes/$_flag_theme.css
end
if set -q _flag_f
set format $_flag_format
end
if set -q _flag_o
set output $_flag_output
end
end
function set_metadata