mirror of
https://github.com/jorgebucaran/fisher
synced 2024-10-09 09:36:53 +02:00
ee0338d5b0
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.
139 lines
3.7 KiB
Fish
139 lines
3.7 KiB
Fish
function fisher_update -d "Update Plugins and Fisherman"
|
|
set -l path
|
|
set -l items
|
|
set -l option self
|
|
set -l error /dev/stderr
|
|
|
|
getopts $argv | while read -l 1 2
|
|
switch "$1"
|
|
case - _
|
|
set option
|
|
set items $items $2
|
|
|
|
case index
|
|
set option index
|
|
|
|
case path
|
|
set option path
|
|
set path $2
|
|
|
|
case q quiet
|
|
set error $2
|
|
|
|
case help
|
|
set option help
|
|
|
|
case h
|
|
printf "usage: fisher update [<plugins>] [--quiet] [--help]\n\n"
|
|
|
|
printf " -q --quiet Enable quiet mode\n"
|
|
printf " -h --help Show usage help \n"
|
|
return
|
|
|
|
case \*
|
|
printf "fisher: Ahoy! '%s' is not a valid option\n" $1 >& 2
|
|
fisher_update -h >& 2
|
|
return 1
|
|
end
|
|
end
|
|
|
|
switch "$option"
|
|
case help
|
|
fisher help update
|
|
return
|
|
end
|
|
|
|
if test -z "$error"
|
|
set error /dev/null
|
|
end
|
|
|
|
switch "$option"
|
|
case path
|
|
if not test -d $path
|
|
printf "fisher: '%s' invalid path\n" $path > $error
|
|
return 1
|
|
end
|
|
|
|
wait --spin=pipe --log=$fisher_error_log "
|
|
|
|
git -C $path checkout --quiet master ^/dev/null
|
|
git -C $path pull --quiet --rebase origin master
|
|
|
|
"
|
|
|
|
case index
|
|
mkdir -p $fisher_cache
|
|
set -l index $fisher_cache/.index.tmp
|
|
|
|
if wait --spin=pipe --log=$fisher_error_log "
|
|
curl --max-time $fisher_timeout -sS $fisher_index > $index
|
|
"
|
|
mv -f $index $fisher_cache/.index
|
|
else
|
|
printf "fisher: Connection timeout. Try again.\n" > $error
|
|
end
|
|
|
|
rm -f $index
|
|
|
|
case self
|
|
set -l time (date +%s)
|
|
|
|
printf "Updating >> Fisherman\n" > $error
|
|
|
|
if not fisher_update --path=$fisher_home --quiet=$error
|
|
printf "fisher: Could not update Fisherman.\n" > $error
|
|
sed -E 's/.*(error:.*)/\1/' $fisher_error_log > $error
|
|
return 1
|
|
end
|
|
|
|
printf "Done without errors (%0.fs)\n" (math (date +%s) - $time) > $error
|
|
|
|
case \*
|
|
set -l time (date +%s)
|
|
set -l count 0
|
|
set -l index 1
|
|
set -l total (count $items)
|
|
|
|
if set -q items[1]
|
|
printf "%s\n" $items
|
|
else
|
|
__fisher_file -
|
|
|
|
end | __fisher_validate | __fisher_cache $error | while read -l path
|
|
|
|
set -l name (printf "%s\n" $path | __fisher_name)
|
|
|
|
printf "Updating " > $error
|
|
|
|
switch $total
|
|
case 0 1
|
|
printf ">> %s\n" $name > $error
|
|
|
|
case \*
|
|
set index (math $index + 1)
|
|
printf "(%s of %s) >> %s\n" $index $total $name > $error
|
|
end
|
|
|
|
if not fisher_update --path=$path --quiet
|
|
if test ! -L $path
|
|
sed -nE 's/.*(error|fatal): (.*)/error: \2/p
|
|
' $fisher_error_log > $error
|
|
continue
|
|
end
|
|
end
|
|
|
|
fisher install --quiet -- $name
|
|
|
|
set count (math $count + 1)
|
|
end
|
|
|
|
set time (math (date +%s) - $time)
|
|
|
|
if test $count = 0
|
|
printf "No plugins were updated.\n" > $error
|
|
return 1
|
|
end
|
|
|
|
printf "Aye! %d plugin/s updated in %0.fs\n" > $error $count $time
|
|
end
|
|
end
|