2015-08-28 02:55:29 +08:00
|
|
|
function omf.remove_package
|
2015-08-30 06:24:51 +08:00
|
|
|
|
2015-09-13 05:50:22 +08:00
|
|
|
set -l pkg $argv
|
|
|
|
set -l remove_status 1
|
|
|
|
|
|
|
|
if not omf.util_valid_package $pkg
|
|
|
|
if test $pkg = "omf" -o $pkg = "default"
|
|
|
|
echo (omf::err)"You can't remove `$pkg`"(omf::off) 1^&2
|
|
|
|
else
|
|
|
|
echo (omf::err)"$pkg is not a valid package/theme name"(omf::off) 1^&2
|
2015-08-26 23:20:13 +08:00
|
|
|
end
|
2015-09-13 05:50:22 +08:00
|
|
|
return $OMF_INVALID_ARG
|
|
|
|
end
|
2015-08-26 23:20:13 +08:00
|
|
|
|
2015-09-13 05:50:22 +08:00
|
|
|
for path in {$OMF_PATH,$OMF_CONFIG}/{pkg}/$pkg
|
|
|
|
not test -d $path; and continue
|
2015-08-30 02:10:47 +08:00
|
|
|
|
2015-09-13 05:50:22 +08:00
|
|
|
emit uninstall_$pkg
|
|
|
|
omf.bundle.remove "package" $pkg
|
2015-08-30 06:24:51 +08:00
|
|
|
|
2015-09-13 05:50:22 +08:00
|
|
|
rm -rf $path
|
|
|
|
set remove_status $status
|
|
|
|
end
|
2015-08-30 02:10:47 +08:00
|
|
|
|
2015-09-13 05:50:22 +08:00
|
|
|
for path in {$OMF_PATH,$OMF_CONFIG}/{themes}/$pkg
|
|
|
|
not test -d $path; and continue
|
2015-08-30 02:10:47 +08:00
|
|
|
|
2015-09-13 05:50:22 +08:00
|
|
|
if test $pkg = (cat $OMF_CONFIG/theme)
|
|
|
|
echo default > $OMF_CONFIG/theme
|
|
|
|
end
|
2015-08-30 02:10:47 +08:00
|
|
|
|
2015-09-13 05:50:22 +08:00
|
|
|
omf.bundle.remove "theme" $pkg
|
2015-08-30 06:24:51 +08:00
|
|
|
|
2015-09-13 05:50:22 +08:00
|
|
|
rm -rf $path
|
|
|
|
set remove_status $status
|
|
|
|
end
|
2015-08-30 02:10:47 +08:00
|
|
|
|
2015-09-13 05:50:22 +08:00
|
|
|
if test $remove_status -eq 0
|
|
|
|
echo (omf::em)"$pkg successfully removed."(omf::off)
|
|
|
|
else
|
|
|
|
echo (omf::err)"$pkg could not be found"(omf::off) 1^&2
|
2015-08-26 23:20:13 +08:00
|
|
|
end
|
2015-09-13 05:50:22 +08:00
|
|
|
return $remove_status
|
2015-08-27 02:15:05 +08:00
|
|
|
end
|