mirror of
https://github.com/jorgebucaran/fisher
synced 2024-11-03 15:40:27 +00:00
Add instrumentation using fishery/debug.
This commit is contained in:
parent
3516a80aee
commit
89c01dc235
@ -1,4 +1,6 @@
|
||||
function __fisher_deps_install -a path
|
||||
debug "Install dependencies in '%s'" "$path"
|
||||
|
||||
for file in $path/{fishfile,bundle}
|
||||
if test -s $file
|
||||
fisher_install < $file | sed -En 's/^.+([0-9]+) plugin\/s.*/\1/p'
|
||||
|
@ -6,6 +6,8 @@ function __fisher_file_remove -a plugin file
|
||||
set pattern "/^$pattern\$/d"
|
||||
end
|
||||
|
||||
debug "Remove '%s' from fishfile '%s'" "$plugin" "$file"
|
||||
|
||||
sed -E "$pattern" < $file > $file.tmp
|
||||
|
||||
command mv $file.tmp $file
|
||||
|
@ -1,6 +1,8 @@
|
||||
function __fisher_gist_to_name -a url
|
||||
set -l id (printf "%s\n" "$url" | sed 's|.*/||')
|
||||
|
||||
debug "Get Gist information '%s'" $url
|
||||
|
||||
set -l name (
|
||||
spin "curl -Ss https://api.github.com/gists/$id" | awk '
|
||||
|
||||
|
@ -7,20 +7,24 @@ function __fisher_index_update -a timeout
|
||||
end
|
||||
end
|
||||
|
||||
debug "Update index with timeout '%.1f'" $timeout
|
||||
|
||||
set -l url $fisher_index
|
||||
set -l index $fisher_cache/.index.tmp
|
||||
|
||||
if test -z "$url"
|
||||
|
||||
# Force the server to return the latest copy of the index using a fake query string.
|
||||
|
||||
set url https://raw.githubusercontent.com/fisherman/fisher-index/master/index\?(date +%s)
|
||||
end
|
||||
|
||||
if not curl --max-time $timeout -sS "$url" > $index
|
||||
debug "Update index fail"
|
||||
|
||||
command rm -f $index
|
||||
return 1
|
||||
end
|
||||
|
||||
debug "Update index complete"
|
||||
|
||||
command mv -f $index $fisher_cache/.index
|
||||
end
|
||||
|
@ -10,6 +10,8 @@ function __fisher_key_bindings_disable -a plugin user_key_bindings
|
||||
command mv -f $fisher_binds.tmp $fisher_binds
|
||||
|
||||
if test ! -s $fisher_binds
|
||||
debug "Remove fisherman key bindings '%s'" "$user_key_bindings"
|
||||
|
||||
sed -i.tmp '/__fisher_key_bindings/d' $user_key_bindings
|
||||
command rm -f $user_key_bindings.tmp
|
||||
end
|
||||
|
@ -12,6 +12,8 @@ function __fisher_key_bindings_enable -a plugin user_key_bindings
|
||||
source $user_key_bindings
|
||||
end
|
||||
|
||||
debug "Add fisherman key bindings '%s'" "$user_key_bindings"
|
||||
|
||||
functions fish_user_key_bindings \
|
||||
| __fisher_key_bindings_update_user > $user_key_bindings
|
||||
end
|
||||
|
@ -5,5 +5,6 @@ function __fisher_key_bindings_update_user
|
||||
}
|
||||
|
||||
$0 !~ "^[ \t]*" src { print }
|
||||
|
||||
' | fish_indent
|
||||
end
|
||||
|
@ -3,11 +3,15 @@ function __fisher_path_make -a path
|
||||
return
|
||||
end
|
||||
|
||||
debug "Makefile '%s'" "$path/Makefile"
|
||||
|
||||
pushd $path
|
||||
|
||||
set -e argv[1]
|
||||
|
||||
if not make $argv
|
||||
debug "Make fail '%s'" "$argv"
|
||||
|
||||
popd
|
||||
return 1
|
||||
end
|
||||
|
@ -1,8 +1,10 @@
|
||||
function __fisher_path_update -a path
|
||||
pushd $path
|
||||
|
||||
debug "Update repository '%s'" "$path"
|
||||
|
||||
git checkout master --quiet ^ /dev/null
|
||||
git pull --rebase origin master --quiet
|
||||
git pull --rebase origin master --quiet
|
||||
|
||||
popd
|
||||
end
|
||||
|
@ -2,6 +2,8 @@ function __fisher_plugin_disable -a plugin path option
|
||||
__fisher_plugin_walk "$plugin" "$path" | while read -l class source target name
|
||||
switch "$class"
|
||||
case --bind
|
||||
debug "Disable key bindings '%s'" $plugin
|
||||
|
||||
__fisher_key_bindings_disable $plugin (__fisher_xdg --config
|
||||
)/fish/functions/fish_user_key_bindings.fish
|
||||
|
||||
@ -18,6 +20,8 @@ function __fisher_plugin_disable -a plugin path option
|
||||
end
|
||||
|
||||
if test -s $fisher_file
|
||||
debug "Remove '%s' from fishfile" "$plugin"
|
||||
|
||||
__fisher_file_remove (
|
||||
if not fisher_search --name=$plugin --name --index=$fisher_cache/.index
|
||||
__fisher_url_from_path $path
|
||||
|
@ -2,6 +2,8 @@ function __fisher_plugin_enable -a plugin path
|
||||
if __fisher_path_is_prompt $path
|
||||
if test ! -z "$fisher_prompt"
|
||||
|
||||
debug "Disable current prompt to install '%s'" $plugin
|
||||
|
||||
# Why do we need to disable a prompt before installing another? I thought
|
||||
# one prompt would override the other?
|
||||
|
||||
@ -33,6 +35,8 @@ function __fisher_plugin_enable -a plugin path
|
||||
__fisher_plugin_walk "$plugin" "$path" | while read -l class source target __unused
|
||||
switch "$class"
|
||||
case --bind
|
||||
debug "Enable key bindings in '%s'" $source
|
||||
|
||||
__fisher_key_bindings_enable $plugin (__fisher_xdg --config
|
||||
)/fish/functions/fish_user_key_bindings.fish < $source
|
||||
|
||||
@ -58,9 +62,13 @@ function __fisher_plugin_enable -a plugin path
|
||||
|
||||
if test -s $fisher_file
|
||||
if __fisher_file_contains "$item" --quiet $fisher_file
|
||||
debug "Skip '%s' already in fishfile" $item
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
debug "Adding '%s' to fishfile" $item
|
||||
|
||||
printf "%s\n" $item >> $fisher_file
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
function __fisher_plugin_link -a options source target
|
||||
debug "Link '%s'" $target
|
||||
|
||||
command ln $options $source $target
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
function __fisher_plugin_source -a plugin file
|
||||
debug "Source '%s'" $file
|
||||
|
||||
source "$file" ^ /dev/null
|
||||
end
|
||||
|
@ -1,4 +1,7 @@
|
||||
function __fisher_plugin_unlink -a name file
|
||||
debug "Unlink '%s'" $file
|
||||
command rm -f $file
|
||||
|
||||
debug "Erase function '%s'" $name
|
||||
functions -e $name
|
||||
end
|
||||
|
@ -13,7 +13,6 @@ function __fisher_plugin_validate -a plugin
|
||||
printf "%s\n" $plugin
|
||||
|
||||
case \*
|
||||
|
||||
printf "$PWD/%s/%s" (dirname $plugin) (basename $plugin)
|
||||
|
||||
end | sed -E 's|[./]*$||; s|/([\./])/+|/|g'
|
||||
|
@ -1,8 +1,12 @@
|
||||
function __fisher_plugin_walk -a plugin path
|
||||
debug "Walk tree in '%s'" "$path"
|
||||
|
||||
for file in $path/{*,{conf.d,modules}/*,functions/**}.{fish,load} $path/completions/*.fish
|
||||
set -l name (basename $file .fish)
|
||||
set -l base $name.fish
|
||||
|
||||
debug "File '%s'" $file
|
||||
|
||||
switch $file
|
||||
case \*/{fish_user_,}key_bindings.fish
|
||||
printf "%s %s %s\n" --bind $file
|
||||
@ -17,6 +21,7 @@ function __fisher_plugin_walk -a plugin path
|
||||
switch "$base"
|
||||
case \*$plugin\*
|
||||
case \*
|
||||
debug "Rename '%s' to '%s'" $plugin $plugin.$base
|
||||
set base $plugin.$base
|
||||
end
|
||||
|
||||
@ -30,11 +35,15 @@ function __fisher_plugin_walk -a plugin path
|
||||
for file in $path/{functions/,}*.{py,rb,php,pl,awk,sed}
|
||||
set -l base (basename $file)
|
||||
|
||||
debug "Script file '%s'" $file
|
||||
|
||||
printf "%s %s %s\n" -- $file functions/$base
|
||||
end
|
||||
|
||||
for n in (seq 9)
|
||||
for file in $path/man/man$n/*.$n
|
||||
debug "Manual page '%s'" $file
|
||||
|
||||
printf "%s %s %s\n" --man $file man/man$n/(basename $file)
|
||||
end
|
||||
end
|
||||
|
@ -1,4 +1,6 @@
|
||||
function __fisher_prompt_reset
|
||||
debug "Reset prompt '%s'" "$fisher_prompt"
|
||||
|
||||
set -U fisher_prompt
|
||||
|
||||
# To reset the prompt, remove any data in fisher_prompt and source any existing
|
||||
@ -10,6 +12,8 @@ function __fisher_prompt_reset
|
||||
|
||||
for prompt in $argv/functions/fish_prompt.fish
|
||||
if test -s $prompt
|
||||
debug "Default prompt '%s'" $prompt
|
||||
|
||||
source $prompt
|
||||
return
|
||||
end
|
||||
|
2
functions/debug.fish
Normal file
2
functions/debug.fish
Normal file
@ -0,0 +1,2 @@
|
||||
function debug
|
||||
end
|
@ -39,12 +39,12 @@ function fisher_install -d "Install Plugins"
|
||||
set -l skipped
|
||||
|
||||
if set -q plugins[1]
|
||||
|
||||
printf "%s\n" $plugins
|
||||
else
|
||||
__fisher_file
|
||||
|
||||
end | while read -l item
|
||||
debug "Validate '%s'" $item
|
||||
|
||||
if not set item (__fisher_plugin_validate $item)
|
||||
printf "fisher: '%s' is not a valid name, path or URL.\n" $item > $stderr
|
||||
@ -53,6 +53,8 @@ function fisher_install -d "Install Plugins"
|
||||
|
||||
switch "$item"
|
||||
case https://gist.github.com\*
|
||||
debug "Install a Gist '%s'" $item
|
||||
|
||||
if set -l name (__fisher_gist_to_name $item)
|
||||
printf "%s %s\n" $item $name
|
||||
else
|
||||
@ -61,13 +63,19 @@ function fisher_install -d "Install Plugins"
|
||||
end
|
||||
|
||||
case \*/\*
|
||||
debug "Install from a URL or path '%s'" $item
|
||||
|
||||
printf "%s %s\n" $item (printf "%s\n" $item | __fisher_name)
|
||||
|
||||
case \*
|
||||
if set -l url (fisher_search --url --name=$item --index=$fisher_cache/.index)
|
||||
debug "Install '%s'" $item
|
||||
|
||||
printf "%s %s\n" $url $item
|
||||
|
||||
else if test -d $fisher_cache/$item
|
||||
debug "Install from '%s'" \$fisher_cache/$item
|
||||
|
||||
printf "%s %s\n" (__fisher_url_from_path $fisher_cache/$item) $item
|
||||
|
||||
else
|
||||
@ -103,10 +111,15 @@ function fisher_install -d "Install Plugins"
|
||||
|
||||
if test ! -e $path
|
||||
if test -d "$url"
|
||||
command ln -sfF $url $path
|
||||
debug "Link '%s' to the cache" $url
|
||||
|
||||
else if not spin "__fisher_url_clone $url $path" --error=$stderr
|
||||
continue
|
||||
command ln -sfF $url $path
|
||||
else
|
||||
debug "Download '%s'" $url
|
||||
|
||||
if not spin "__fisher_url_clone $url $path" --error=$stderr
|
||||
continue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -135,8 +148,12 @@ function fisher_install -d "Install Plugins"
|
||||
return 1
|
||||
end
|
||||
|
||||
debug "Pre-reset completions and key bindings"
|
||||
|
||||
__fisher_complete_reset
|
||||
__fisher_key_bindings_reset
|
||||
|
||||
debug "Post-reset completions and key bindings"
|
||||
|
||||
printf "Aye! %d plugin/s installed in %0.fs\n" $count $time > $stdout
|
||||
end
|
||||
|
@ -87,6 +87,8 @@ function fisher_search -d "Search Plugins"
|
||||
end
|
||||
|
||||
if test $fisher_last_update -gt $fisher_update_interval -o ! -f $index
|
||||
debug "Update index"
|
||||
|
||||
if spin "__fisher_index_update" --error=/dev/null
|
||||
__fisher_complete_reset
|
||||
end
|
||||
|
@ -45,6 +45,8 @@ function fisher_uninstall -d "Uninstall Plugins"
|
||||
|
||||
end | while read -l item path
|
||||
|
||||
debug "Validate '%s'" $item
|
||||
|
||||
if not set item (__fisher_plugin_validate $item)
|
||||
printf "fisher: '%s' is not a valid name, path or url.\n" $item > $stderr
|
||||
continue
|
||||
@ -58,6 +60,8 @@ function fisher_uninstall -d "Uninstall Plugins"
|
||||
|
||||
set -l name (printf "%s\n" $path | __fisher_name)
|
||||
|
||||
debug "Uninstall '%s' in '%s'" "$name" "$path"
|
||||
|
||||
if not contains -- $name (__fisher_list $fisher_file)
|
||||
if test -z "$option"
|
||||
set total (math $total - 1)
|
||||
@ -78,10 +82,14 @@ function fisher_uninstall -d "Uninstall Plugins"
|
||||
end
|
||||
|
||||
if __fisher_plugin_can_enable "$name" "$path"
|
||||
debug "Plugin disable '%s' w/ option '%s'" "$name" "$option"
|
||||
|
||||
__fisher_plugin_disable "$name" "$path" "$option"
|
||||
end
|
||||
|
||||
if test "$option" = force
|
||||
debug "Remove path '%s'" "$path"
|
||||
|
||||
command rm -rf $path
|
||||
end
|
||||
|
||||
@ -101,8 +109,12 @@ function fisher_uninstall -d "Uninstall Plugins"
|
||||
return 1
|
||||
end
|
||||
|
||||
debug "Pre-reset completions and key bindings"
|
||||
|
||||
__fisher_complete_reset
|
||||
__fisher_key_bindings_reset
|
||||
|
||||
debug "Post-reset completions and key bindings"
|
||||
|
||||
printf "Aye! %d plugin/s uninstalled in %0.fs\n" $count $time > $stdout
|
||||
end
|
||||
|
@ -34,19 +34,22 @@ function fisher_update -d "Update Plugins/Fisherman"
|
||||
case self
|
||||
set -l time (date +%s)
|
||||
|
||||
debug "Update Fisherman"
|
||||
|
||||
printf "Updating >> Fisherman\n" > $stderr
|
||||
|
||||
if not spin "
|
||||
__fisher_index_update 0
|
||||
__fisher_path_update $fisher_home" --error=$stderr
|
||||
|
||||
###
|
||||
###
|
||||
debug "Update Fisherman fail"
|
||||
|
||||
printf "fisher: Arrr! Could not update Fisherman.\n" > $stderr
|
||||
return 1
|
||||
end
|
||||
|
||||
debug "Update Fisherman complete"
|
||||
|
||||
printf "Aye! Fisherman updated to version %s (%0.fs)\n" (
|
||||
cat $fisher_home/VERSION) (math (date +%s) - $time) > $stderr
|
||||
|
||||
@ -64,6 +67,8 @@ function fisher_update -d "Update Plugins/Fisherman"
|
||||
|
||||
end | while read -l item path
|
||||
|
||||
debug "Validate '%s'" $item
|
||||
|
||||
if not set item (__fisher_plugin_validate $item)
|
||||
printf "fisher: '%s' is not a valid name, path or url.\n" $item > $stderr
|
||||
continue
|
||||
@ -89,12 +94,16 @@ function fisher_update -d "Update Plugins/Fisherman"
|
||||
end
|
||||
|
||||
if test ! -L $path
|
||||
debug "Update plugin '%s'" "$name"
|
||||
|
||||
if not spin "__fisher_path_update $path" --error=$stderr
|
||||
continue
|
||||
end
|
||||
end
|
||||
|
||||
if __fisher_plugin_can_enable "$name" "$path"
|
||||
debug "Install to enable '%s'" "$name"
|
||||
|
||||
fisher_install --quiet --force -- $name
|
||||
end
|
||||
|
||||
|
@ -1,8 +1,19 @@
|
||||
# Reset Fisherman's configuration state.
|
||||
|
||||
if functions -q debug
|
||||
functions -c debug debug_copy
|
||||
end
|
||||
|
||||
set -g fisher_config $argv
|
||||
|
||||
source $fisher_home/config.fish
|
||||
|
||||
if functions -q debug
|
||||
functions -e debug
|
||||
functions -c debug_copy debug
|
||||
functions -e debug_copy
|
||||
end
|
||||
|
||||
set -U fisher_prompt
|
||||
set -g plugins $DIRNAME/fixtures/plugins
|
||||
set -g fisher_index file://$plugins/index
|
||||
|
Loading…
Reference in New Issue
Block a user