2015-08-27 20:05:19 +00:00
|
|
|
function omf.install -a type_flag name_or_url
|
2015-08-29 22:24:15 +00:00
|
|
|
function _display_success
|
2015-09-06 20:01:11 +00:00
|
|
|
echo (omf::em)"✔ $argv successfully installed."(omf::off)
|
2015-08-29 22:24:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function _display_error
|
|
|
|
echo (omf::err)"Could not install $argv."(omf::off) 1^&2
|
|
|
|
return $OMF_UNKNOWN_ERR
|
|
|
|
end
|
|
|
|
|
2015-08-27 20:05:19 +00:00
|
|
|
switch $type_flag
|
|
|
|
case "--theme"
|
|
|
|
set install_type "theme"
|
|
|
|
set parent_path "themes"
|
|
|
|
case "--pkg"
|
|
|
|
set install_type "package"
|
|
|
|
set parent_path "pkg"
|
|
|
|
case "*"
|
|
|
|
echo (omf::err)"Argument to omf.install must be --theme [name|URL] or --pkg [name|URL]"(omf::off)
|
|
|
|
return $OMF_INVALID_ARG
|
|
|
|
end
|
2015-08-28 16:08:40 +00:00
|
|
|
|
2015-08-27 20:05:19 +00:00
|
|
|
if test -e $OMF_PATH/db/$parent_path/$name_or_url
|
|
|
|
set target $parent_path/$name_or_url
|
|
|
|
else
|
2015-09-03 18:49:34 +00:00
|
|
|
set -l local_name (basename $name_or_url | sed "s/^pkg-//;s/^plugin-//;s/^theme-//")
|
2015-08-27 20:05:19 +00:00
|
|
|
if test -e $OMF_PATH/$parent_path/$local_name
|
|
|
|
echo (omf::err)"Error: $local_name $install_type already installed."(omf::off) 1^&2
|
|
|
|
else
|
|
|
|
echo (omf::dim)"Trying to clone from URL..."(omf::off)
|
2015-09-06 00:55:52 +00:00
|
|
|
if omf.repo.clone $name_or_url $OMF_PATH/$parent_path/$local_name
|
2015-09-07 22:34:11 +00:00
|
|
|
omf.bundle.add $install_type $name_or_url
|
2015-08-29 22:24:15 +00:00
|
|
|
_display_success "$install_type $name_or_url"
|
|
|
|
else
|
|
|
|
_display_error "$install_type $name_or_url"
|
2015-08-27 20:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
|
|
|
if test -e $OMF_PATH/$target
|
|
|
|
echo (omf::dim)"Updating $name_or_url $install_type..."(omf::off)
|
2015-09-17 17:39:15 +00:00
|
|
|
omf.repo.pull $OMF_PATH/$target
|
2015-08-27 20:05:19 +00:00
|
|
|
echo (omf::em)"✔ $name_or_url $install_type up to date."(omf::off)
|
|
|
|
else
|
|
|
|
echo (omf::dim)"Installing $name_or_url $install_type..."(omf::off)
|
2015-09-06 00:55:52 +00:00
|
|
|
if omf.repo.clone (cat $OMF_PATH/db/$target) $OMF_PATH/$target
|
2015-09-07 22:34:11 +00:00
|
|
|
omf.bundle.add $install_type $name_or_url
|
2015-08-29 22:24:15 +00:00
|
|
|
_display_success "$install_type $name_or_url"
|
|
|
|
else
|
|
|
|
_display_error "$install_type $name_or_url"
|
2015-08-27 20:05:19 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|