oh-my-fish/pkg/omf/cli/omf.submit.fish
Bruno Pinto 20ed43983b Naming functions with omf. namespace.
Having a clear namespace `omf.` improves the readability of the code as
we clarify what is the function name and what is the namespace.
2015-08-28 18:24:56 +09:00

43 lines
1.3 KiB
Fish

# SYNOPSIS
# Submit a package to the registry
#
# OPTIONS
# name Name of the package.
# [url] URL to the package repository.
function omf.submit -a name url -d "Submit a package to the registry"
switch (dirname $name)
case pkg
case themes
case "*"
echo (omf::err)"Missing directory name: pkg/ or themes/"(omf::off) 1^&2
return $OMF_INVALID_ARG
end
set -l pkg (basename $name)
if not omf.util_valid_package $pkg
echo (omf::err)"$pkg is not a valid package/theme name"(omf::off) 1^&2
return $OMF_INVALID_ARG
end
if test -z "$url"
echo (omf::em)"URL not specified, looking for a remote origin..."(omf::off) 1^&2
set url (git config --get remote.origin.url)
if test -z "$url"
echo (omf::em)"$pkg remote URL not found"(omf::off) 1^&2
echo "Try: git remote add <URL> or see Docs#Submitting" 1^&2
return $OMF_INVALID_ARG
end
else
if test -e "$OMF_PATH/db/$name"
echo (omf::err)"Error: $pkg already exists in the registry!"(omf::off) 1^&2
return $OMF_INVALID_ARG
else
echo "$url" > $OMF_PATH/db/$name
echo (omf::em)"$pkg added to the local "(dirname $name)" registry."(omf::off)
echo "Want to contribute? Send us a PR → github.com/fish-shell/omf"
return 0
end
end
end