2015-08-26 23:20:13 +08:00
|
|
|
function omf_new -a option name
|
|
|
|
switch $option
|
|
|
|
case "p" "pkg" "pack" "packg" "package"
|
|
|
|
set option "pkg"
|
|
|
|
case "t" "th" "the" "thm" "theme" "themes"
|
|
|
|
set option "themes"
|
|
|
|
case "*"
|
|
|
|
echo (omf::err)"$option is not a valid option."(omf::off) 1^&2
|
|
|
|
return $OMF_INVALID_ARG
|
|
|
|
end
|
|
|
|
|
|
|
|
if not omf_util_valid_package "$name"
|
|
|
|
echo (omf::err)"$name is not a valid package/theme name"(omf::off) 1^&2
|
|
|
|
return $OMF_INVALID_ARG
|
|
|
|
end
|
|
|
|
|
|
|
|
if set -l dir (omf_util_mkdir "$option/$name")
|
|
|
|
cd $dir
|
|
|
|
|
|
|
|
set -l github (git config github.user)
|
|
|
|
test -z "$github"; and set github "{{USERNAME}}"
|
|
|
|
|
|
|
|
set -l user (git config user.name)
|
|
|
|
test -z "$user"; and set user "{{USERNAME}}"
|
|
|
|
|
2015-08-27 03:43:01 +08:00
|
|
|
omf_new_from_template "$OMF_PATH/pkg/omf/templates/$option" \
|
2015-08-26 23:20:13 +08:00
|
|
|
$github $user $name
|
|
|
|
|
|
|
|
echo (omf::em)"Switched to $dir"(omf::off)
|
|
|
|
else
|
|
|
|
echo (omf::err)"\$OMF_CUSTOM and/or \$OMF_PATH undefined."(omf::off) 1^&2
|
|
|
|
exit $OMF_UNKNOWN_ERR
|
|
|
|
end
|
|
|
|
end
|