mirror of
https://github.com/jorgebucaran/fisher
synced 2024-11-09 07:10:27 +00:00
Improve Install/Update/Uninstall message channels.
Before this commit, both error and success information was sent to stderr. Now, the total number of plugins installed / updated / uninstalled is sent to stdout allowing us to parse this output and implement a more robust (and simpler) __fisher_deps_install
This commit is contained in:
parent
5faf3a7812
commit
778b5279c5
@ -1,7 +1,8 @@
|
||||
function fisher_install -d "Install Plugins"
|
||||
set -l plugins
|
||||
set -l option
|
||||
set -l error /dev/stderr
|
||||
set -l stdout /dev/stdout
|
||||
set -l stderr /dev/stderr
|
||||
|
||||
getopts $argv | while read -l 1 2
|
||||
switch "$1"
|
||||
@ -12,7 +13,8 @@ function fisher_install -d "Install Plugins"
|
||||
set option force
|
||||
|
||||
case q quiet
|
||||
set error /dev/null
|
||||
set stdout /dev/null
|
||||
set stderr /dev/null
|
||||
|
||||
case h
|
||||
printf "usage: fisher install [<plugins>] [--force] [--quiet] [--help]\n\n"
|
||||
@ -23,8 +25,8 @@ function fisher_install -d "Install Plugins"
|
||||
return
|
||||
|
||||
case \*
|
||||
printf "fisher: '%s' is not a valid option.\n" $1 >& 2
|
||||
fisher_install -h >& 2
|
||||
printf "fisher: '%s' is not a valid option.\n" $1 >& /dev/stderr
|
||||
fisher_install -h >& /dev/stderr
|
||||
return 1
|
||||
end
|
||||
end
|
||||
@ -45,7 +47,7 @@ function fisher_install -d "Install Plugins"
|
||||
end | while read -l item
|
||||
|
||||
if not set item (__fisher_plugin_validate $item)
|
||||
printf "fisher: '%s' is not a valid name, path or url.\n" $item > $error
|
||||
printf "fisher: '%s' is not a valid name, path or url.\n" $item > $stderr
|
||||
continue
|
||||
end
|
||||
|
||||
@ -62,7 +64,7 @@ function fisher_install -d "Install Plugins"
|
||||
|
||||
else
|
||||
set total (math $total - 1)
|
||||
printf "fisher: '%s' not found.\n" $item > $error
|
||||
printf "fisher: '%s' not found.\n" $item > $stderr
|
||||
end
|
||||
end
|
||||
|
||||
@ -76,14 +78,14 @@ function fisher_install -d "Install Plugins"
|
||||
end
|
||||
end
|
||||
|
||||
printf "Installing " > $error
|
||||
printf "Installing " > $stderr
|
||||
|
||||
switch $total
|
||||
case 0 1
|
||||
printf ">> %s\n" $name > $error
|
||||
printf ">> %s\n" $name > $stderr
|
||||
|
||||
case \*
|
||||
printf "(%s of %s) >> %s\n" $index $total $name > $error
|
||||
printf "(%s of %s) >> %s\n" $index $total $name > $stderr
|
||||
set index (math $index + 1)
|
||||
end
|
||||
|
||||
@ -96,11 +98,11 @@ function fisher_install -d "Install Plugins"
|
||||
ln -sfF $url $path
|
||||
|
||||
else if not wait "__fisher_url_clone $url $path"
|
||||
printf "fisher: Repository not found: '%s'\n" $url > $error
|
||||
printf "fisher: Repository not found: '%s'\n" $url > $stderr
|
||||
|
||||
switch "$url"
|
||||
case \*oh-my-fish\*
|
||||
printf "Did you miss a 'plugin-' or 'theme-' prefix?\n" > $error
|
||||
printf "Did you miss a 'plugin-' or 'theme-' prefix?\n" > $stderr
|
||||
end
|
||||
|
||||
continue
|
||||
@ -110,7 +112,7 @@ function fisher_install -d "Install Plugins"
|
||||
set -l deps (__fisher_deps_install "$path")
|
||||
|
||||
if not __fisher_path_make "$path" --quiet
|
||||
printf "fisher: Failed to build '%s'. See '%s/Makefile'.\n" $name $path > $error
|
||||
printf "fisher: Failed to build '%s'. See '%s/Makefile'.\n" $name $path > $stderr
|
||||
end
|
||||
|
||||
__fisher_plugin_enable "$name" "$path"
|
||||
@ -122,16 +124,16 @@ function fisher_install -d "Install Plugins"
|
||||
|
||||
if test ! -z "$skipped"
|
||||
printf "%s plugin/s skipped (%s)\n" (count $skipped) (
|
||||
printf "%s\n" $skipped | paste -sd ' ' -) > $error
|
||||
printf "%s\n" $skipped | paste -sd ' ' -) > $stdout
|
||||
end
|
||||
|
||||
if test "$count" -le 0
|
||||
printf "No plugins were installed.\n" > $error
|
||||
printf "No plugins were installed.\n" > $stdout
|
||||
return 1
|
||||
end
|
||||
|
||||
__fisher_complete_reset
|
||||
__fisher_key_bindings_reset
|
||||
|
||||
printf "Aye! %d plugin/s installed in %0.fs\n" $count $time > $error
|
||||
printf "Aye! %d plugin/s installed in %0.fs\n" $count $time > $stdout
|
||||
end
|
||||
|
@ -1,7 +1,8 @@
|
||||
function fisher_uninstall -d "Uninstall Plugins"
|
||||
set -l plugins
|
||||
set -l option
|
||||
set -l error /dev/stderr
|
||||
set -l stdout /dev/stdout
|
||||
set -l stderr /dev/stderr
|
||||
|
||||
getopts $argv | while read -l 1 2
|
||||
switch "$1"
|
||||
@ -12,7 +13,8 @@ function fisher_uninstall -d "Uninstall Plugins"
|
||||
set option force
|
||||
|
||||
case q quiet
|
||||
set error /dev/null
|
||||
set stdout /dev/null
|
||||
set stderr /dev/null
|
||||
|
||||
case h
|
||||
printf "usage: fisher uninstall [<plugins>] [--force] [--quiet] [--help]\n\n"
|
||||
@ -23,8 +25,8 @@ function fisher_uninstall -d "Uninstall Plugins"
|
||||
return
|
||||
|
||||
case \*
|
||||
printf "fisher: '%s' is not a valid option.\n" $1 >& 2
|
||||
fisher_uninstall -h >& 2
|
||||
printf "fisher: '%s' is not a valid option.\n" $1 >& /dev/stderr
|
||||
fisher_uninstall -h >& /dev/stderr
|
||||
return 1
|
||||
end
|
||||
end
|
||||
@ -44,13 +46,13 @@ function fisher_uninstall -d "Uninstall Plugins"
|
||||
end | while read -l item path
|
||||
|
||||
if not set item (__fisher_plugin_validate $item)
|
||||
printf "fisher: '%s' is not a valid name, path or url.\n" $item > $error
|
||||
printf "fisher: '%s' is not a valid name, path or url.\n" $item > $stderr
|
||||
continue
|
||||
end
|
||||
|
||||
if not set path (__fisher_path_from_plugin $item)
|
||||
set total (math $total - 1)
|
||||
printf "fisher: '%s' not found\n" $item > $error
|
||||
printf "fisher: '%s' not found\n" $item > $stderr
|
||||
continue
|
||||
end
|
||||
|
||||
@ -64,14 +66,14 @@ function fisher_uninstall -d "Uninstall Plugins"
|
||||
end
|
||||
end
|
||||
|
||||
printf "Uninstalling " > $error
|
||||
printf "Uninstalling " > $stderr
|
||||
|
||||
switch $total
|
||||
case 0 1
|
||||
printf ">> %s\n" $name > $error
|
||||
printf ">> %s\n" $name > $stderr
|
||||
|
||||
case \*
|
||||
printf "(%s of %s) >> %s\n" $index $total $name > $error
|
||||
printf "(%s of %s) >> %s\n" $index $total $name > $stderr
|
||||
set index (math $index + 1)
|
||||
end
|
||||
|
||||
@ -95,16 +97,17 @@ function fisher_uninstall -d "Uninstall Plugins"
|
||||
|
||||
if test ! -z "$skipped"
|
||||
printf "%s plugin/s skipped (%s)\n" (count $skipped) (
|
||||
printf "%s\n" $skipped | paste -sd ' ' -) > $error
|
||||
printf "%s\n" $skipped | paste -sd ' ' -
|
||||
) > $stdout
|
||||
end
|
||||
|
||||
if test $count -le 0
|
||||
printf "No plugins were uninstalled.\n" > $error
|
||||
printf "No plugins were uninstalled.\n" > $stdout
|
||||
return 1
|
||||
end
|
||||
|
||||
__fisher_complete_reset
|
||||
__fisher_key_bindings_reset
|
||||
|
||||
printf "Aye! %d plugin/s uninstalled in %0.fs\n" > $error $count $time
|
||||
printf "Aye! %d plugin/s uninstalled in %0.fs\n" $count $time > $stdout
|
||||
end
|
||||
|
@ -1,16 +1,21 @@
|
||||
function fisher_update -d "Update Plugins/Fisherman"
|
||||
set -l plugins
|
||||
set -l option self
|
||||
set -l error /dev/stderr
|
||||
set -l stdout /dev/stdout
|
||||
set -l stderr /dev/stderr
|
||||
|
||||
getopts $argv | while read -l 1 2
|
||||
switch "$1"
|
||||
case - _
|
||||
case _
|
||||
set option
|
||||
set plugins $plugins $2
|
||||
|
||||
if test "$2" != -
|
||||
set plugins $plugins $2
|
||||
end
|
||||
|
||||
case q quiet
|
||||
set error /dev/null
|
||||
set stdout /dev/null
|
||||
set stderr /dev/null
|
||||
|
||||
case h
|
||||
printf "usage: fisher update [<plugins>] [--quiet] [--help]\n\n"
|
||||
@ -19,8 +24,8 @@ function fisher_update -d "Update Plugins/Fisherman"
|
||||
return
|
||||
|
||||
case \*
|
||||
printf "fisher: '%s' is not a valid option.\n" $1 >& 2
|
||||
fisher_update -h >& 2
|
||||
printf "fisher: '%s' is not a valid option.\n" $1 >& /dev/stderr
|
||||
fisher_update -h >& /dev/stderr
|
||||
return 1
|
||||
end
|
||||
end
|
||||
@ -29,11 +34,11 @@ function fisher_update -d "Update Plugins/Fisherman"
|
||||
case self
|
||||
set -l time (date +%s)
|
||||
|
||||
printf "Updating >> Fisherman\n" > $error
|
||||
printf "Updating >> Fisherman\n" > $stderr
|
||||
|
||||
if not wait "__fisher_index_update; __fisher_path_update $fisher_home"
|
||||
printf "fisher: Arrr! Could not update Fisherman.\n" > $error
|
||||
sed -E 's/.*error: (.*)/\1/' $fisher_cache/.debug > $error
|
||||
printf "fisher: Arrr! Could not update Fisherman.\n" > $stderr
|
||||
sed -E 's/.*error: (.*)/\1/' $fisher_cache/.debug > $stderr
|
||||
return 1
|
||||
end
|
||||
|
||||
@ -47,7 +52,7 @@ function fisher_update -d "Update Plugins/Fisherman"
|
||||
#############################
|
||||
|
||||
printf "Aye! Fisherman updated to version %s (%0.fs)\n" (
|
||||
cat $fisher_home/VERSION) (math (date +%s) - $time) > $error
|
||||
cat $fisher_home/VERSION) (math (date +%s) - $time) > $stderr
|
||||
|
||||
case \*
|
||||
set -l time (date +%s)
|
||||
@ -57,7 +62,6 @@ function fisher_update -d "Update Plugins/Fisherman"
|
||||
set -l skipped
|
||||
|
||||
if set -q plugins[1]
|
||||
|
||||
printf "%s\n" $plugins
|
||||
else
|
||||
__fisher_file
|
||||
@ -65,33 +69,33 @@ function fisher_update -d "Update Plugins/Fisherman"
|
||||
end | while read -l item path
|
||||
|
||||
if not set item (__fisher_plugin_validate $item)
|
||||
printf "fisher: '%s' is not a valid name, path or url.\n" $item > $error
|
||||
printf "fisher: '%s' is not a valid name, path or url.\n" $item > $stderr
|
||||
continue
|
||||
end
|
||||
|
||||
if not set path (__fisher_path_from_plugin $item)
|
||||
set total (math $total - 1)
|
||||
printf "fisher: '%s' not found.\n" $item > $error
|
||||
printf "fisher: '%s' not found.\n" $item > $stderr
|
||||
continue
|
||||
end
|
||||
|
||||
set -l name (printf "%s\n" $path | __fisher_name)
|
||||
|
||||
printf "Updating " > $error
|
||||
printf "Updating " > $stderr
|
||||
|
||||
switch $total
|
||||
case 0 1
|
||||
printf ">> %s\n" $name > $error
|
||||
printf ">> %s\n" $name > $stderr
|
||||
|
||||
case \*
|
||||
printf "(%s of %s) >> %s\n" $index $total $name > $error
|
||||
printf "(%s of %s) >> %s\n" $index $total $name > $stderr
|
||||
set index (math $index + 1)
|
||||
end
|
||||
|
||||
if not wait "__fisher_path_update $path"
|
||||
if not wait "__fisher_path_update $path" --log=$fisher_cache/.debug
|
||||
if test ! -L $path
|
||||
sed -nE 's/.*(error|fatal): (.*)/error: \2/p
|
||||
' $fisher_cache/.debug > $error
|
||||
' $fisher_cache/.debug > $stderr
|
||||
continue
|
||||
end
|
||||
end
|
||||
@ -104,10 +108,10 @@ function fisher_update -d "Update Plugins/Fisherman"
|
||||
set time (math (date +%s) - $time)
|
||||
|
||||
if test $count -le 0
|
||||
printf "No plugins were updated.\n" > $error
|
||||
printf "No plugins were updated.\n" > $stdout
|
||||
return 1
|
||||
end
|
||||
|
||||
printf "Aye! %d plugin/s updated in %0.fs\n" > $error $count $time
|
||||
printf "Aye! %d plugin/s updated in %0.fs\n" $count $time > $stdout
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user