fisher/functions/fisher_uninstall.fish
Jorge Bucaran 5dc1eea953
Ahoy! an early v0.7.0 is here!
+ Add  the ability  to install plugins  from Gists.  You can
distribute a very simple,  one-single function plugin in the
form  of a  Gist. Your  users  can install  it using  fisher
install  url and  Fisherman will  query the  Gist using  the
GitHub API to get a list of  the Gist files and use the name
of the  first identified *.fish  file to name the  plugin in
your system.  Since there is no  formal way to name  a Gist,
and you may  prefer to keep the "description"  field for the
actual description  and not a name,  Fisherman supports only
one fish file per Gist. Closes #75.

+ Use command(1) when calling non-builtins. Thanks @daenney.
Closes #79.

+  Add  __fisher_plugin_can_enable  to detect  installing  a
prompt that is not the current one. Closes #78.

+  Remove  the ability  to  install  a  plugin in  a  parent
directory using ..  or ../ or even worse, ../../  as well as
other combinations  that navigate  to a parent  directory. I
find  the use  case odd  at  best, and  more dangerous  that
useful.  If you  want  to  install a  local  plugin use  the
full  path  or a  relative  path,  always top  down.  fisher
install  . or  fisher  install my/plugin  or fisher  install
/Users/$USER/path/to/plugin. Closes #81.
2016-02-11 09:40:03 +09:00

109 lines
2.8 KiB
Fish

function fisher_uninstall -d "Uninstall Plugins"
set -l plugins
set -l option
set -l stdout /dev/stdout
set -l stderr /dev/stderr
getopts $argv | while read -l 1 2
switch "$1"
case _
set plugins $plugins $2
case f force
set option force
case q quiet
set stdout /dev/null
set stderr /dev/null
case h
printf "usage: fisher uninstall [<plugins>] [--force] [--quiet] [--help]\n\n"
printf " -f --force Delete copy from cache\n"
printf " -q --quiet Enable quiet mode\n"
printf " -h --help Show usage help\n"
return
case \*
printf "fisher: '%s' is not a valid option.\n" $1 > /dev/stderr
fisher_uninstall -h > /dev/stderr
return 1
end
end
set -l time (date +%s)
set -l count 0
set -l index 1
set -l total (count $plugins)
set -l skipped
if set -q plugins[1]
printf "%s\n" $plugins
else
__fisher_file
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 > $stderr
continue
end
if not set path (__fisher_path_from_plugin $item)
set total (math $total - 1)
printf "fisher: '%s' not found\n" $item > $stderr
continue
end
set -l name (printf "%s\n" $path | __fisher_name)
if not contains -- $name (__fisher_list $fisher_file)
if test -z "$option"
set total (math $total - 1)
set skipped $skipped $name
continue
end
end
printf "Uninstalling " > $stderr
switch $total
case 0 1
printf ">> %s\n" $name > $stderr
case \*
printf "(%s of %s) >> %s\n" $index $total $name > $stderr
set index (math $index + 1)
end
if __fisher_plugin_can_enable "$name" "$path"
__fisher_plugin_disable "$name" "$path"
end
if test "$option" = force
command rm -rf $path
end
set count (math $count + 1)
end
set time (math (date +%s) - $time)
if test ! -z "$skipped"
printf "%s plugin/s skipped (%s)\n" (count $skipped) (
printf "%s\n" $skipped | paste -sd ' ' -
) > $stdout
end
if test $count -le 0
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" $count $time > $stdout
end