fisher/functions/__fisher_plugin_validate.fish
Jorge Bucaran 6c5cac3a18
Ahoy! Fisherman 1.4.0 has shipped.
Notable changes:

+ Now fisher list does not show plugins that are disabled,
  but available in the cache. To preview these items use
  fisher list --disabled.

+ Welcome aboard @orangecms and @xrain0610.

+ Fisherman is now available in AUR, thanks @orangecms.

+ Fix load order during installation. Now snippets can
  safely invoke functions defined in the plugin function
  directory. Thanks @orangecms. #170.

+ Fisherman **installs and updates plugins ⌁concurrently**.
  Performance may vary, but if you can see 5 to 10 times
  faster network times, it's working well.
2016-03-31 02:42:44 +09:00

57 lines
1.6 KiB
Fish

function __fisher_plugin_validate -a plugin
if test -z "$plugin"
return 1
end
if set -q argv[2]
printf "%s\n" "$argv"
return 1
end
switch "$plugin"
case ..\*
printf "%s\n" "../"
return 1
case . ./\* /\*
if test ! -e "$plugin"
printf "%s\n" $plugin
return 1
end
set plugin (
switch "$plugin"
case /\*
printf "%s\n" $plugin
case \*
printf "$PWD/%s/%s" (dirname "$plugin") (basename "$plugin")
end | sed -E 's|[./]*$||; s|/([\./])/+|/|g'
)
printf "%s\n" $plugin
__fisher_plugin_validate (basename $plugin) > /dev/null
case \*
set -l id "[A-Za-z0-9._-]"
if not printf "%s\n" "$plugin" | grep -qE "^(($id+)[:/]*)*\$"
printf "%s\n" "$plugin"
return 1
end
printf "%s\n" "$plugin" | sed -E "
s|^gh[:/]+|https://github.com/|
s|^gl[:/]+|https://gitlab.com/|
s|^bb[:/]+|https://bitbucket.org/|
s|^omf[:/]+|https://github.com/oh-my-fish/|
s|^($id+)/($id+)\$|https://github.com/\1/\2|
s|^(gist\.github\.com.*)|https://\1|
s|^http(s?)[:/]*|http\1://|
s|https://github((.com)?/)?|https://github.com/|
s|/*(\.git/*)*\$||g" | tr "[A-Z]" "[a-z]"
end
end