oh-my-fish/pkg/omf/functions/omf.fish
Pablo Santiago Blum de Aguiar a4b2f1cfaa Remove occurrences of ? as a glob
Since Fish Shell 3.0 [1], `?` as a glob is deprecated. Fixes #644

  1. https://github.com/fish-shell/fish-shell/releases/tag/3.0.0
2019-02-13 09:24:22 +01:00

52 lines
1.1 KiB
Fish

function omf -d "Oh My Fish"
# Parse any options before the command name.
while set -q argv[1]
switch $argv[1]
case '-h' '--help'
set command help
case '-v' '--version'
set command version
case '-*'
echo (omf::err)"Unknown option: $argv[1]"(omf::off) >&2
return $OMF_UNKNOWN_OPT
case '*'
break
end
set -e argv[1]
end
# Also extract a help flag from the last argument.
switch "$argv[-1]"
case '-h' '--help'
set command help
set -e argv[-1]
end
# Extract the command name from the remaining arguments.
if not set -q command
if set -q argv[1]
set command $argv[1]
set -e argv[1]
else
set command help
end
end
# Lookup the function for the requested command.
if not set command_name (omf.command $command)
echo (omf::err)"Unknown command: $command"(omf::off) >&2
return $OMF_UNKNOWN_OPT
end
# Execute the command.
echo "function __omf_last_command --no-scope-shadowing
omf.cli.$command_name \$argv
end" | source
__omf_last_command $argv
end