mirror of
https://github.com/oh-my-fish/oh-my-fish
synced 2024-11-09 13:10:40 +00:00
centralize pkg / theme installation
This commit is contained in:
parent
f7677581fa
commit
c6e72863bd
47
pkg/omf/cli/omf.install.fish
Normal file
47
pkg/omf/cli/omf.install.fish
Normal file
@ -0,0 +1,47 @@
|
||||
function omf.install -a type_flag name_or_url
|
||||
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
|
||||
|
||||
if test -e $OMF_PATH/db/$parent_path/$name_or_url
|
||||
set target $parent_path/$name_or_url
|
||||
else
|
||||
set -l local_name (basename $name_or_url)
|
||||
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)
|
||||
git clone -q $name_or_url $OMF_PATH/$parent_path/$local_name
|
||||
and echo (omf::em)"✔ $local_name $install_type succesfully installed."(omf::off)
|
||||
or begin
|
||||
echo (omf::err)"$local_name is not a valid $install_type."(omf::off) 1^&2
|
||||
return $OMF_INVALID_ARG
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
if test -e $OMF_PATH/$target
|
||||
echo (omf::dim)"Updating $name_or_url $install_type..."(omf::off)
|
||||
pushd $OMF_PATH/$target
|
||||
omf.util_sync "origin" >/dev/null ^&1
|
||||
popd
|
||||
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)
|
||||
git clone (cat $OMF_PATH/db/$target) $OMF_PATH/$target >/dev/null ^&1
|
||||
and echo (omf::em)"✔ $name_or_url $install_type successfully installed."(omf::off)
|
||||
or begin
|
||||
echo (omf::err)"Could not install $install_type."(omf::off) 1^&2
|
||||
return $OMF_UNKNOWN_ERR
|
||||
end
|
||||
end
|
||||
end
|
@ -1,33 +1,5 @@
|
||||
function omf.install_package
|
||||
for search in $argv
|
||||
if test -e $OMF_PATH/db/pkg/$search
|
||||
set target pkg/$search
|
||||
else if test -e $OMF_PATH/db/themes/$search
|
||||
set target themes/$search
|
||||
else
|
||||
set -l pkg (basename $search)
|
||||
if test -e $OMF_PATH/pkg/$pkg
|
||||
echo (omf::err)"Error: $pkg already installed."(omf::off) 1^&2
|
||||
else
|
||||
echo (omf::dim)"Trying to clone from URL..."(omf::err)
|
||||
git clone -q $search $OMF_PATH/pkg/$pkg
|
||||
and echo (omf::em)"✔ $pkg succesfully installed."(omf::off)
|
||||
or echo (omf::err)"$pkg is not a valid package/theme."(omf::off) 1^&2
|
||||
end
|
||||
continue
|
||||
end
|
||||
|
||||
if test -e $OMF_PATH/$target
|
||||
echo (omf::dim)"Updating $search..."(omf::off)
|
||||
pushd $OMF_PATH/$target
|
||||
omf.util_sync "origin" >/dev/null ^&1
|
||||
popd
|
||||
echo (omf::em)"✔ $search up to date."(omf::off)
|
||||
else
|
||||
echo (omf::dim)"Installing $search..."(omf::off)
|
||||
git clone (cat $OMF_PATH/db/$target) $OMF_PATH/$target >/dev/null ^&1
|
||||
and echo (omf::em)"✔ $search succesfully installed."(omf::off)
|
||||
or echo (omf::err)"Could not install package."(omf::off) 1^&2
|
||||
end
|
||||
omf.install --pkg $search
|
||||
end
|
||||
end
|
||||
|
@ -1,17 +1,6 @@
|
||||
function omf.theme
|
||||
if not test -e $OMF_CONFIG/themes/$argv[1]
|
||||
if not test -e $OMF_PATH/themes/$argv[1]
|
||||
set -l theme $OMF_PATH/db/themes/$argv[1]
|
||||
if test -e $theme
|
||||
echo (omf::dim)"Downloading $argv[1] theme..."(omf::off)
|
||||
git clone (cat $theme) $OMF_PATH/themes/$argv[1] >/dev/null ^&1
|
||||
and echo (omf::em)"$argv[1] theme downloaded."(omf::off)
|
||||
or return $OMF_UNKNOWN_ERR
|
||||
else
|
||||
echo (omf::err)"$argv[1] is not a valid theme"(omf::off) 1^&2
|
||||
return $OMF_INVALID_ARG
|
||||
end
|
||||
end
|
||||
omf.install --theme $argv[1]
|
||||
end
|
||||
echo "$argv[1]" > $OMF_CONFIG/theme
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user