oh-my-fish/pkg/omf/functions/packages/omf.packages.remove.fish
Derek Stavis 49dda5c2f7 Reorganize omf plugin structure
This updates omf plugin to new architecture, moving
functions to `functions` directory. It also revamps the
separation of concerns between CLI and underlying
implementations, organizing them into directories,
whose are autoloaded in plugin startup.
2016-01-09 18:59:54 -02:00

47 lines
954 B
Fish

function omf.packages.remove -a pkg
if not omf.packages.valid_name $pkg
echo (omf::err)"$pkg is not a valid package/theme name"(omf::off) 1>&2
return $OMF_INVALID_ARG
end
if test $pkg = "omf" -o $pkg = "default"
echo (omf::err)"You can't remove `$pkg`"(omf::off) 1>&2
return $OMF_INVALID_ARG
end
for path in {$OMF_PATH,$OMF_CONFIG}/pkg/$pkg
test -d $path;
and set found;
or continue
source $path/uninstall.fish ^/dev/null;
and emit uninstall_$pkg
if rm -rf $path
omf.bundle.remove "package" $pkg
return 0
else
return 1
end
end
for path in {$OMF_PATH,$OMF_CONFIG}/themes/$pkg
test -d $path;
and set found;
or continue
test $pkg = (cat $OMF_CONFIG/theme);
and echo default > $OMF_CONFIG/theme
if rm -rf $path
omf.bundle.remove "theme" $pkg
return 0
else
return 1
end
end
set -q found; or return 2
end