Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

191 lines (161 sloc) 4.779 kB
#!/usr/bin/env bash
ext_help()
{
modules ext/help
description "BDSM extension ext management"
action "ext" "List installed ext."
action "ext known" "List extension ext that can be installed."
action_separator
action "ext install all" "Install all extension ext found on the known list."
action "ext install {name}" "Install extension {name} found on the known list."
action "ext install {name} {uri}" "Install extension {name} from the given {uri}."
action "ext add" "Shortcut for install."
action_separator
action "ext update all" "Update all extension ext using remembered uris."
action "ext update {name}" "Update extension {name} using remembered uri."
action "ext up" "Shortcut for update."
action_separator
action "ext uninstall {name}" "Remove extension {name}."
action "ext del" "Shortcut for uninstall."
action_separator
action "ext help" "Show this help."
show_help usage
}
ext_list()
{
local extensions COLUMNS=80
if extensions_in "${extension_exts_path}"
then
log "exts: #system"
echo ${found_extensions[@]} | xargs -s ${COLUMNS} | xargs -I '{}' echo " - {}"
else
log "# No single system extensions (exts) are currently installed."
fi
if [[ "${extension_exts_path}" != "${extension_exts_home}" ]]
then
if extensions_in "${extension_exts_home}"
then
log "exts: #user"
echo ${found_extensions[@]} | xargs -s ${COLUMNS} | xargs -I '{}' echo " - {}"
else
log "# No single user extensions (exts) are currently installed."
fi
fi
}
ext_list_known()
{
local COLUMNS=80
awk -F = '/^[^#]/ {printf "# %18s | %s\n", $1, $2 }' <<<"Extension name=Repository"
awk -F = '/^[^#]/ {printf "%20s %s\n", $1, $2 }' < "${sm_path}/core/cli/config/known_ext"
}
ext_install()
{
local _name _names="${1:-}" _uri=${2:-}
shift || fail "$FUNCNAME: Cannot install a ext; No ext name was given."
_names=(${_names//,/ })
for _name in ${_names[@]}
do
log_step "sm_${_name}" extension_install "${_name}" ${_uri}
done
}
extension_install()
{
local _name="${1:-}"
shift || fail "$FUNCNAME: Cannot install extension; No extension name was given."
local _uri="${1:-}"
shift || _uri=$( awk -F = "/^${_name}=/ {print \$2 }" < "${sm_path}/core/cli/config/known_ext" | tail -n 1 )
local _identifier="$(scm_identifier "${_uri}")"
[[ -n "${_uri}" ]] ||
error "$FUNCNAME: uri not given and cannot find ${_name} in known extensions."
local _identifier="$(scm_identifier "${_uri}")"
ensure_paths_exist "${extension_exts_home}"
enter "${extension_exts_home}"
fetch_uri "${_uri}" "${src_path}/${_identifier}" "$@" || return $?
remove_paths "${_name}"
copy_directory "${src_path}/${_identifier}" to "${_name}"
}
ext_install_all()
{
local _set _name _uri COLUMNS=80
for _set in $( awk '/^[^#]/' < "${sm_path}/core/cli/config/known_ext" )
do
_name="${_set%%=*}"
_uri="${_set##*=}"
ext_install "${_name}" "${_uri}"
done
}
ext_update()
{
local _name _uri
if [[ -z "$1" ]]
then
error "Cannot update extension ext without name."
fi
for _name in "$@"
do
if [[ ! -d "${extension_exts_home}/${_name}" ]]
then
if [[ -d "${extension_exts_path}/${_name}" ]]
then
error "Extension ${_name} is in system exts and cannot be updated."
else
error "Extension ${_name} does not exist."
fi
fi
if [[ ! -s "${extension_exts_home}/${_name}/.uri" ]]
then
log "Extension ${_name} does not contain stored uri."
continue
fi
_uri=$( cat "${extension_exts_home}/${_name}/.uri" )
if [[ -z "${_uri}" ]]
then
log "Extension ${_name} does not contain stored uri."
else
ext_install "${_name}" "${_uri}"
fi
done
}
ext_update_all()
{
local _name
for _name in ${extension_exts_home}/*
do
case "${_name##*/}" in
\*)
error "No extensions found for update."
;;
*)
ext_update "${_name##*/}"
;;
esac
done
}
ext_uninstall()
{
local _name="$1"
case "${_name}" in
*/*|.|..)
error "Please specify a valid extension name."
;;
esac
enter "${extension_exts_home}"
if [[ ! -d "${_name}" ]]
then
if [[ -d "${extension_exts_path}/${_name}" ]]
then
error "Extension ${_name} is in system exts and cannot be uninstalled."
else
error "Extension ${_name} does not exist."
fi
fi
#TODO: are you sure ?
log "Uninstalling extension: ${_name}."
rm -rf "${_name}"
}
ext_check_availability()
{
awk -F = '/^[^#]/ {printf "%20s %s\n", $1, $2 }' < "${sm_path}/core/cli/config/known_ext" |
"${sm_path}/bin/sm-ll" \
printf "%s: " {} \; curl -s --head https://github.com/wayneeseguin/sm-{} \| awk "'/Status/{print \$2}'"
}
Jump to Line
Something went wrong with that request. Please try again.