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." end if test -z "$argv[1]" read -f input else set input $argv[1] end if not set -q _flag_r string unescape --style=url "$input" | string replace -a ' ' '\\ ' | string replace 'file://' '' else printf 'file://%s\n' (string replace '\\ ' ' ' "$input" | string escape --style=url) end end