function uri-path argparse h/help r/reverse -- $argv if set -q _flag_h echo "Convert a file URI to a Path." echo "-h/--help for help." echo "-r/--reverse to convert a path to URI." return 0 end if test -z "$argv" read -f input else set input $argv end if not set -q _flag_r string unescape --style=url "$input" | string replace 'file://' '' else printf 'file://%s\n' (string escape --style=url "$input") end end