2015-12-20 17:57:51 -02:00
|
|
|
function omf.packages.remove -a pkg
|
|
|
|
|
|
|
|
if not omf.packages.valid_name $pkg
|
2016-12-17 20:26:46 -06:00
|
|
|
echo (omf::err)"$pkg is not a valid package/theme name"(omf::off) >&2
|
2015-12-20 17:57:51 -02:00
|
|
|
return $OMF_INVALID_ARG
|
|
|
|
end
|
|
|
|
|
|
|
|
if test $pkg = "omf" -o $pkg = "default"
|
2016-12-17 20:26:46 -06:00
|
|
|
echo (omf::err)"You can't remove `$pkg`"(omf::off) >&2
|
2015-12-20 17:57:51 -02:00
|
|
|
return $OMF_INVALID_ARG
|
|
|
|
end
|
|
|
|
|
|
|
|
for path in {$OMF_PATH,$OMF_CONFIG}/pkg/$pkg
|
|
|
|
test -d $path;
|
|
|
|
and set found;
|
|
|
|
or continue
|
|
|
|
|
2016-07-18 17:57:54 -05:00
|
|
|
# Run uninstall hook first.
|
|
|
|
omf.packages.run_hook $path uninstall
|
2018-06-08 23:58:16 +03:00
|
|
|
source $path/uninstall.fish 2> /dev/null;
|
2015-12-20 17:57:51 -02:00
|
|
|
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
|