fisher/functions/__fisher_validate.fish
Jorge Bucaran 707855203a Ahoy! Fisherman gets a super patch v0.3.1
This patch contains several amends for 0.3.0 and
other minor documentation corrections.  Major
documentation revision and rewrite.

fisher help shows fisher(1) by default now.

Fix a critical bug that was causing fisher uninstall
--force to remove not the symbolic link, but the
actual files. Closes #24

Rename orphan tag to custom for plugins installed
using a custom URL.

warning Remove fisher --link flag and create symbolic
links by default for local paths. The user does not
have to worry about symbolic links or whether the
copy is as symbolic link or not anymore. If the user
tries to install a local path, then the best thing
to do is to create a symbolic link. This also
eliminates the need to call update.

warning Remove fisher --cache and fisher --validate.
Now, that these options are separated into their own
function and they are intentionally private, there
is no need for them.
2016-01-10 16:13:46 +09:00

44 lines
1.4 KiB
Fish

function __fisher_validate -d "Validate a name, url or path"
set -l id "[A-Za-z0-9_]+([.-]?[A-Za-z0-9_])*"
if not set -q fisher_default_host
set fisher_default_host https://github.com
end
while read -lp "" item
switch "$item"
case \*..\* /. /
return 1
end
if test -e "$item"
if test $item = $HOME -o $HOME = $PWD
return 1
end
if test -f "$item"
set item (dirname $item)
end
if not printf "%s\n" $item | grep "^\/"
printf "$PWD/%s/%s" (dirname $item) (basename $item)
end | sed -E 's|^/|file:///|;s|[./]*$||'
else
printf "%s\n" $item | sed -En "
s#plg?ug?i?n#plugin#
s#oh?my?i?f[iy]?h?si?h?#oh-my-fish#
s#/\$##
s#\.git\$##
s#^(https?):*/* *(.*\$)#\1://\2#p
s#^(@|(gh[:/])|(github(.com)?[/:]))/?($id)/($id)\$#https://github.com/\5/\7#p
s#^(bb[:/])/*($id)/($id)\$#https://bitbucket.org/\2/\4#p
s#^(gl[:/])/*($id)/($id)\$#https://gitlab.com/\2/\4#p
s#^(omf[:/])/*($id)\$#https://github.com/oh-my-fish/\2#p
s#^($id)/($id)\$#$fisher_default_host/\1/\3#p
/^file:\/\/\/.*/p
/^[a-z]+([._-]?[a-z0-9]+)*\$/p"
end
end
end