mirror of
https://github.com/jorgebucaran/fisher
synced 2024-08-17 12:31:05 +02:00
Bring spin back to avoid installing issues. Spin for everyone.
This commit is contained in:
parent
ae3992338c
commit
5659c469b0
7 changed files with 206 additions and 27 deletions
2
completions/spin.fish
Normal file
2
completions/spin.fish
Normal file
|
@ -0,0 +1,2 @@
|
|||
set -l IFS \t
|
||||
spin -h | __fisher_complete spin
|
|
@ -1,3 +1,73 @@
|
|||
function spin -a commands
|
||||
fish -c "$commands" ^ /dev/null
|
||||
function spin -d "Background job spinner"
|
||||
set -l format " @\r"
|
||||
set -l commands
|
||||
set -l spinners "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"
|
||||
set -l error /dev/stderr
|
||||
|
||||
getopts $argv | while read -l 1 2
|
||||
switch "$1"
|
||||
case _
|
||||
set commands $commands ";$2"
|
||||
|
||||
case s style
|
||||
set spinners $2
|
||||
|
||||
case f format
|
||||
set format $2
|
||||
|
||||
case error
|
||||
set error $2
|
||||
|
||||
case h help
|
||||
printf "Usage: spin <commands> [--style=<style>] [--format=<string>] \n"
|
||||
printf " [--error=<file>] [--help]\n\n"
|
||||
|
||||
printf " -s --style=<string> Use <string> to slice the spinner characters\n"
|
||||
printf " -f --format=<format> Use <format> to customize the spinner display\n"
|
||||
printf " --error=<file> Write errors to <file>\n"
|
||||
printf " -h --help Show usage help\n"
|
||||
return
|
||||
|
||||
case \*
|
||||
printf "spin: '%s' is not a valid option\n" $1 > /dev/stderr
|
||||
spin -h > /dev/stderr
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
if not set -q commands[1]
|
||||
return 1
|
||||
end
|
||||
|
||||
set spinners (printf "%s\n" "$spinners" | grep -o .)
|
||||
|
||||
set -l tmp (mktemp -t spin.XXX)
|
||||
set -l job_id
|
||||
|
||||
fish -c "$commands" > /dev/stdout ^ $tmp &
|
||||
|
||||
set job_id (jobs -l | cut -d\t -f1)
|
||||
|
||||
while contains -- $job_id (jobs | cut -d\t -f1 ^ /dev/null)
|
||||
if status --is-interactive
|
||||
for i in $spinners
|
||||
printf "$format" | awk -v i=(printf "%s\n" $i | sed 's/=/\\\=/') '
|
||||
{
|
||||
gsub("@", i)
|
||||
printf("%s", $0)
|
||||
}
|
||||
' > /dev/stderr
|
||||
|
||||
sleep 0.01
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if test -s $tmp
|
||||
command cat $tmp > $error
|
||||
command rm -f $tmp
|
||||
return 1
|
||||
end
|
||||
|
||||
command rm -f $tmp
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "FISHER\-UNINSTALL" "1" "February 2016" "" "fisherman"
|
||||
.TH "FISHER\-UNINSTALL" "1" "March 2016" "" "fisherman"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBfisher\-uninstall\fR \- Uninstall plugins
|
||||
|
@ -29,13 +29,13 @@ fisher uninstall \fIowner/repo\fR
|
|||
.br
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
Uninstall one or more plugins, by name, URL or path\. If no arguments are given, read the standard input\. This process is the inverse of Install\.
|
||||
Uninstall one or more plugins\. If no arguments are given, read the standard input\.
|
||||
.
|
||||
.P
|
||||
Uninstall does not remove any copies of the given plugin in $fisher_cache\. To erase the copy from the cache, use the \-\-force option\.
|
||||
.
|
||||
.P
|
||||
Uninstall does not remove any dependencies installed with other plugins\. This behavior prevents breaking plugins that share the same dependency\.
|
||||
Uninstall does not remove any dependencies installed with other plugins\.
|
||||
.
|
||||
.SH "OPTIONS"
|
||||
.
|
||||
|
@ -54,7 +54,7 @@ Show usage help\.
|
|||
.SH "EXAMPLES"
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
Uninstall all plugins and flush the cache\.
|
||||
Uninstall all plugins flushing the cache\.
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
|
@ -62,7 +62,7 @@ Uninstall all plugins and flush the cache\.
|
|||
.
|
||||
.nf
|
||||
|
||||
fisher \-\-list | fisher uninstall \-\-force
|
||||
fisher list | fisher uninstall \-\-force
|
||||
.
|
||||
.fi
|
||||
.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "FISHER\-UPDATE" "1" "February 2016" "" "fisherman"
|
||||
.TH "FISHER\-UPDATE" "1" "March 2016" "" "fisherman"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBfisher\-update\fR \- Update plugins
|
||||
|
@ -26,10 +26,7 @@ fisher update \fIowner/repo\fR \.\.\.
|
|||
.br
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
Update one or more plugins, by name, URL or path\. If no arguments are given, update Fisherman to the latest release\. If you try to update a plugin that is currently disabled, but exists in the cache, it will be updated and then enabled\. Use a dash \fB\-\fR to read from the standard input\.
|
||||
.
|
||||
.P
|
||||
If a plugin is missing dependencies, they will be installed\. If any dependencies are already installed they will not be updated\.
|
||||
Update one or more plugins concurrently\. If no arguments are given, update everything, including Fisherman\. Use a dash \fB\-\fR to read from the standard input\.
|
||||
.
|
||||
.SH "OPTIONS"
|
||||
.
|
||||
|
@ -72,19 +69,4 @@ fisher list | fisher update \-
|
|||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
Update all the plugins in the cache concurrently\.
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
fisher list \-\-bare | xargs \-n1 \-P0 fish \-c "fisher update \-"
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
|
|
60
man/man1/spin.1
Normal file
60
man/man1/spin.1
Normal file
|
@ -0,0 +1,60 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "SPIN" "1" "March 2016" "" "fisherman"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBspin\fR \- Background job spinner
|
||||
.
|
||||
.SH "SYNOPSIS"
|
||||
\fBspin\fR \fIcommands\fR [\fB\-\-style\fR=\fImix\fR|\fIarc\fR|\fIstar\fR|\fIpipe\fR|\fIflip\fR|\fIbounce\fR|\fIbar1~3\fR]
|
||||
.
|
||||
.br
|
||||
\fBspin\fR \fIcommands\fR [\fB\-\-error\fR=file] [\fB\-\-format\fR=format] [\fB\-\-help\fR]
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
\fBSpin\fR is a terminal spinner and progress bar indicator for fish\.
|
||||
.
|
||||
.SH "USAGE"
|
||||
.
|
||||
.nf
|
||||
|
||||
spin "sleep 1"
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.P
|
||||
Spin interprets any output to standard error as failure\. Use \-\-error=\fIfile\fR to redirect the standard error output to \fIfile\fR\.
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
if not spin \-\-style=pipe \-\-error=debug\.txt "curl \-sS $URL"
|
||||
return 1
|
||||
end
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "Options"
|
||||
.
|
||||
.TP
|
||||
\-s, \-\-style=\fIstyle\fR|\fIstring\fR
|
||||
Use \fIstring\fR to slice the spinner characters\. If you don\'t want to display the spinners, use \-\-style=\fI""\fR\.
|
||||
.
|
||||
.TP
|
||||
\-f, \-\-format=\fIformat\fR
|
||||
Use \fIformat\fR to customize the spinner display\. The default format is \fB" @\er"\fR where \fB@\fR represents the spinner token and \fB\er\fR a carriage return, used to refresh (erase) the line\.
|
||||
.
|
||||
.TP
|
||||
\-\-error=\fIfile\fR
|
||||
Write the standard error output to a given \fIfile\fR\.
|
||||
.
|
||||
.TP
|
||||
\-h, \-\-help
|
||||
Show usage help\.
|
||||
.
|
||||
.SS "Customization"
|
||||
Replace the default spinner with your own string of characters\. For example, \-\-style=\fI12345\fR will display the numbers from 1 to 5, and \-\-style=\fI\.\fR \-\-format=\fI@\fR an increasing sequence of dots\.
|
43
man/man1/spin.md
Normal file
43
man/man1/spin.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
spin(1) -- Background job spinner
|
||||
=================================
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
`spin` *commands* [`--style`=*mix*|*arc*|*star*|*pipe*|*flip*|*bounce*|*bar1~3*]<br>
|
||||
`spin` *commands* [`--error`=file] [`--format`=format] [`--help`]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
**Spin** is a terminal spinner and progress bar indicator for fish.
|
||||
|
||||
## USAGE
|
||||
|
||||
```fish
|
||||
spin "sleep 1"
|
||||
```
|
||||
|
||||
Spin interprets any output to standard error as failure. Use --error=*file* to redirect the standard error output to *file*.
|
||||
|
||||
```fish
|
||||
if not spin --style=pipe --error=debug.txt "curl -sS $URL"
|
||||
return 1
|
||||
end
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
* -s, --style=*style*|*string*:
|
||||
Use *string* to slice the spinner characters. If you don't want to display the spinners, use --style=*""*.
|
||||
|
||||
* -f, --format=*format*:
|
||||
Use *format* to customize the spinner display. The default format is `" @\r"` where `@` represents the spinner token and `\r` a carriage return, used to refresh (erase) the line.
|
||||
|
||||
* --error=*file*:
|
||||
Write the standard error output to a given *file*.
|
||||
|
||||
* -h, --help:
|
||||
Show usage help.
|
||||
|
||||
### Customization
|
||||
|
||||
Replace the default spinner with your own string of characters. For example, --style=*12345* will display the numbers from 1 to 5, and --style=*.* --format=*@* an increasing sequence of dots.
|
22
test/spin.fish
Normal file
22
test/spin.fish
Normal file
|
@ -0,0 +1,22 @@
|
|||
test "$TESTNAME: Fail if no commands are given"
|
||||
1 = (
|
||||
spin
|
||||
echo $status
|
||||
)
|
||||
end
|
||||
|
||||
test "$TESTNAME - Fail if there is any output to standard error"
|
||||
ok = (
|
||||
if not spin "echo errored >& 2" --error=/dev/null
|
||||
echo ok
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
test "$TESTNAME - Run commands in the background"
|
||||
3 = (spin "math 1 + 2")
|
||||
end
|
||||
|
||||
test "$TESTNAME - Display help information"
|
||||
(spin -h | xargs) = "Usage: spin <commands> [--style=<style>] [--format=<string>] [--error=<file>] [--help] -s --style=<string> Use <string> to slice the spinner characters -f --format=<format> Use <format> to customize the spinner display --error=<file> Write errors to <file> -h --help Show usage help"
|
||||
end
|
Loading…
Reference in a new issue