mirror of
https://github.com/jorgebucaran/fisher
synced 2024-09-10 15:07:40 +02:00
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.
141 lines
3.7 KiB
Fish
141 lines
3.7 KiB
Fish
function wait -d "Run commands and wait with a spin"
|
||
set -l option
|
||
set -l commands
|
||
set -l spinners
|
||
set -l time 0.03
|
||
set -l log
|
||
set -l format "@\r"
|
||
|
||
getopts $argv | while read -l 1 2
|
||
switch "$1"
|
||
case -
|
||
case _
|
||
set commands $commands ";$2"
|
||
|
||
case s spin spinner{,s} style
|
||
set spinners $spinners $2
|
||
|
||
case t time
|
||
set time $2
|
||
|
||
case l log
|
||
set log $2
|
||
|
||
case f format
|
||
set format $2
|
||
|
||
case help
|
||
set option help
|
||
|
||
case h
|
||
printf "usage: wait <commands> [--spin=<style>] [--time=<delay>] [--log=<file>] \n"
|
||
printf " [--format=<format>] [--help]\n\n"
|
||
|
||
printf " -s --spin=<style> Set spinner style\n"
|
||
printf " -t --time=<delay> Set spinner transition time delay\n"
|
||
printf " -l --log=<file> Output standard error to <file>\n"
|
||
printf " -f --format=<format> Use given <format> to display spinner\n"
|
||
printf " -h --help Show usage help\n"
|
||
return
|
||
|
||
case \*
|
||
printf "wait: '%s' is not a valid option\n" $1 >& 2
|
||
wait -h >& 2
|
||
return 1
|
||
end
|
||
end
|
||
|
||
switch "$option"
|
||
case help
|
||
man wait
|
||
return
|
||
end
|
||
|
||
if not set -q commands[1]
|
||
return 1
|
||
end
|
||
|
||
switch "$spinners"
|
||
case arc star pipe ball flip mixer caret
|
||
set -l arc "◜◠◝◞◡◟"
|
||
set -l star "+x*"
|
||
set -l pipe "-\\|/"
|
||
set -l ball "▖▘▝▗"
|
||
set -l flip "___-``'´-___"
|
||
set -l mixer "⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆"
|
||
set -l caret "II||"
|
||
|
||
set spinners "$$spinners"
|
||
|
||
case bar{1,2,3,\?\?\*}
|
||
set -l bar
|
||
set -l bar1 "[" "=" " " "]" "%"
|
||
set -l bar2 "[" "#" " " "]" "%"
|
||
set -l bar3 "." "." " " " " "%"
|
||
|
||
switch "$spinners"
|
||
case \*{1,2,3}
|
||
case \*
|
||
printf "%s\n" $spinners | sed -E 's/^bar.?//;s/./& /g' | read -az bar
|
||
set spinners bar
|
||
end
|
||
|
||
set -l IFS \t
|
||
printf "%s\t" $$spinners | read -l open fill void close symbol
|
||
|
||
set spinners
|
||
|
||
for i in (seq 5 5 100)
|
||
if test -n "$symbol"
|
||
set symbol "$i%"
|
||
end
|
||
|
||
set -l gap (printf "$void%.0s" (seq (math 100 - $i)))
|
||
|
||
if test $i -ge 100
|
||
set gap ""
|
||
end
|
||
|
||
set spinners $spinners "$open"(printf "$fill%.0s" (seq $i))"$gap$close $symbol"
|
||
end
|
||
end
|
||
|
||
set -l tmp (mktemp -t wait.XXX)
|
||
|
||
fish -c "$commands" ^ $tmp &
|
||
|
||
if not set -q spinners[2]
|
||
set spinners (printf "%s\n" "$spinners" | grep -o .)
|
||
end
|
||
|
||
while true
|
||
if status --is-interactive
|
||
for i in $spinners
|
||
printf "$format" | awk -v t=$time -v i=(printf "%s\n" $i | sed 's/=/\\\=/') '
|
||
{
|
||
system("tput civis")
|
||
gsub("@", i)
|
||
printf("%s", $0)
|
||
system("sleep "t";tput cnorm")
|
||
}
|
||
' > /dev/stderr
|
||
end
|
||
end
|
||
|
||
if test -z (jobs)
|
||
printf "$format" | tr @ "\0" > /dev/stderr
|
||
break
|
||
end
|
||
end
|
||
|
||
if test -s $tmp
|
||
if set -q log[1]
|
||
nl -n ln -- $tmp > $log
|
||
end
|
||
|
||
rm -f $tmp
|
||
return 1
|
||
end
|
||
|
||
rm -f $tmp
|
||
end
|