Skip to content
Browse files

Began log api separation.

  • Loading branch information...
1 parent 0041cf1 commit 5323973798826a885e2c6d8ac18502b47012ae19 @wayneeseguin wayneeseguin committed Sep 13, 2011
Showing with 957 additions and 1,016 deletions.
  1. +3 −6 bin/smp
  2. +16 −16 core/api/shell/array/functions
  3. +6 −6 core/api/shell/command/functions
  4. +12 −12 core/api/shell/config/functions
  5. +3 −3 core/api/shell/database/extensions
  6. +12 −12 core/api/shell/date/functions
  7. +8 −8 core/api/shell/extensions/functions
  8. +23 −23 core/api/shell/files/functions
  9. +5 −5 core/api/shell/hash/functions
  10. +3 −3 core/api/shell/help/functions
  11. +2 −2 core/api/shell/interactive/functions
  12. +5 −5 core/api/shell/logging/functions
  13. +7 −7 core/api/shell/os/functions
  14. +3 −3 core/api/shell/package/extensions
  15. +20 −20 core/api/shell/package/functions
  16. +22 −22 core/api/shell/paths/functions
  17. +3 −3 core/api/shell/service/extensions
  18. +1 −1 core/api/shell/steps/functions
  19. +3 −3 core/api/shell/string/functions
  20. +12 −12 core/api/shell/templates/functions
  21. +3 −3 core/api/shell/time/functions
  22. +4 −4 core/api/shell/traps/functions
  23. +10 −10 core/api/shell/user/functions
  24. +7 −7 core/api/shell/variables/functions
  25. +1 −1 core/cli/bin/call
  26. +5 −5 core/cli/bin/clone
  27. +2 −2 core/cli/bin/console
  28. +3 −3 core/cli/bin/dev/create
  29. +1 −1 core/cli/bin/dev/package
  30. +1 −1 core/cli/bin/dev/publish
  31. +1 −1 core/cli/bin/module_utils/edit
  32. +1 −1 core/cli/bin/module_utils/open
  33. +1 −1 core/cli/bin/module_utils/src
  34. +2 −2 core/cli/bin/open
  35. +2 −2 core/cli/bin/src
  36. +4 −4 core/cli/bin/version
  37. +1 −1 core/cli/bin/website
  38. +9 −9 core/cli/shell/dev/functions
  39. +11 −11 core/cli/shell/ext/functions
  40. +3 −3 core/cli/shell/functions
  41. +2 −2 core/cli/shell/get/functions
  42. +4 −6 core/cli/shell/man/functions
  43. +9 −9 core/cli/shell/module_utils/functions
  44. +12 −12 core/cli/shell/sets/functions
  45. +2 −2 core/cli/shell/smrc/functions
  46. +5 −5 core/cli/shell/templates/functions
  47. +16 −16 core/install/shell/functions
  48. +10 −10 core/internal/shell/array/functions
  49. +1 −1 core/internal/shell/config/extensions
  50. +3 −3 core/internal/shell/database/extensions
  51. +5 −5 core/internal/shell/extensions/cache/functions
  52. +6 −6 core/internal/shell/extensions/common/functions
  53. +3 −3 core/internal/shell/extensions/completion/functions
  54. +16 −16 core/internal/shell/extensions/detection/functions
  55. +1 −1 core/internal/shell/extensions/execution/functions
  56. +10 −10 core/internal/shell/extensions/manipulation/functions
  57. +31 −31 core/internal/shell/files/functions
  58. +3 −3 core/internal/shell/help/functions
  59. +5 −5 core/internal/shell/logging/functions
  60. +4 −4 core/internal/shell/os/functions
  61. +3 −3 core/internal/shell/package/extensions
  62. +60 −60 core/internal/shell/package/functions
  63. +37 −37 core/internal/shell/paths/functions
  64. +2 −2 core/internal/shell/processes/functions
  65. +3 −3 core/internal/shell/service/extensions
  66. +38 −38 core/internal/shell/service/functions
  67. +1 −1 core/internal/shell/steps/functions
  68. +13 −13 core/internal/shell/templates/functions
  69. +1 −1 core/internal/shell/traps/functions
  70. +2 −2 core/internal/shell/user/functions
  71. +2 −2 core/internal/shell/variables/functions
  72. +6 −6 core/internal/shell/vcs/errors/functions
  73. +16 −16 core/internal/shell/vcs/functions
  74. +8 −8 core/internal/shell/vcs/handlers/archive/functions
  75. +4 −4 core/internal/shell/vcs/handlers/git/functions
  76. +6 −6 core/internal/shell/vcs/handlers/github/functions
  77. +2 −2 core/internal/shell/vcs/handlers/hg/functions
  78. +2 −2 core/internal/shell/vcs/handlers/path/functions
  79. +2 −2 core/internal/shell/vcs/handlers/svn/functions
  80. +1 −1 core/sm/shell/core/functions
  81. +1 −1 core/sm/shell/core/initialize
  82. +308 −359 core/sm/shell/logging/functions
  83. +5 −8 core/sm/shell/logging/initialize
  84. +16 −16 core/sm/shell/modules/functions
  85. +3 −3 core/sm/shell/string/functions
  86. +26 −26 core/sm/shell/versionedfs/functions
View
9 bin/smp
@@ -20,21 +20,18 @@ os_cpu_count()
elif os is linux
then
_cpu_count=$(awk '/^processor/{count++} END{print count}' /proc/cpuinfo 2>&1)
-
# Warn that this function has not yet been implemented for solaris.
elif os is solaris
then
- warn "CPU counting for Solaris has not yet been implemented; returning 1."
-
+ __sm.log.warn "CPU counting for Solaris has not yet been implemented; returning 1."
# Warn that this function has not yet been implemented for bsd.
elif os is bsd
then
- warn "CPU counting for BSD has not yet been implemented; returning 1."
-
+ __sm.log.warn "CPU counting for BSD has not yet been implemented; returning 1."
# Warn that this function has not yet been implemented for aix.
elif os is aix
then
- warn "CPU counting for AIX has not yet been implemented; returning 1."
+ __sm.log.warn "CPU counting for AIX has not yet been implemented; returning 1."
fi
(( _cpu_count > 0 )) || _cpu_count=1 # Sanity Check
View
32 core/api/shell/array/functions
@@ -30,12 +30,12 @@ array()
{
trace_filter array
local _command="$1" _subcommand _name _variable
- shift || fail "Array command must be given as the first parameter."
+ shift || __sm.log.fail "Array command must be given as the first parameter."
case "${_command}" in
(is)
_subcommand="$1" _name="$2"
- shift 2 || fail "subcommand and array name missing;"\
+ shift 2 || __sm.log.fail "subcommand and array name missing;"\
" array is <empty,nonempty,even> {name}"
case "${_subcommand}" in
(empty)
@@ -48,78 +48,78 @@ array()
__sm.array.is.even "${_name}"
;;
(*)
- fail "Unknown '${_subcommand}'; array is <empty,nonempty,even> {name}"
+ __sm.log.fail "Unknown '${_subcommand}'; array is <empty,nonempty,even> {name}"
;;
esac
;;
(length)
_name="$1"
- shift || fail "Array name missing: array length {name}"
+ shift || __sm.log.fail "Array name missing: array length {name}"
__sm.array.length "${_name}"
;;
(last)
_name="$1"
- shift || fail "Array name missing: array last {name}"
+ shift || __sm.log.fail "Array name missing: array last {name}"
__sm.array.last "${_name}"
;;
(first)
_name="$1"
- shift || fail "Array name missing: array first {name}"
+ shift || __sm.log.fail "Array name missing: array first {name}"
__sm.array.first "${_name}"
;;
(push)
_name="$1" _element="$2"
- shift 2 || fail "Array name or element missing:"\
+ shift 2 || __sm.log.fail "Array name or element missing:"\
" array push {name} {element}"
__sm.array.push "${_name}" "${_element}"
;;
(pop)
_name="$1" _variable="${2:-}"
- shift || fail "Array name missing: array pop {name} [{variable}]"
+ shift || __sm.log.fail "Array name missing: array pop {name} [{variable}]"
__sm.array.pop "${_name}" "${_variable}"
;;
(append)
_name="$1" _element="$2"
- shift 2 || fail "Array name or element missing:"\
+ shift 2 || __sm.log.fail "Array name or element missing:"\
" array append {name} {element}"
__sm.array.append "${_name}" "${_element}"
;;
(shift)
_name="$1" _variable="${2:-}"
- shift || fail "Array name missing: array shift {name} [{variable}]"
+ shift || __sm.log.fail "Array name missing: array shift {name} [{variable}]"
__sm.array.shift "${_name}" "${_variable}"
;;
(unshift)
_name="$1"
- shift || fail "Array name missing: array unshift {name} [{variable}]"
+ shift || __sm.log.fail "Array name missing: array unshift {name} [{variable}]"
__sm.array.unshift "${_name}" "${_variable}"
;;
(join)
_name="$1" _separator="${2:-' '}"
- shift || fail "Array name missing: array join {name} [separator]"
+ shift || __sm.log.fail "Array name missing: array join {name} [separator]"
__sm.array.join "${_name}" "${_separator}"
;;
(largest)
_name="$1"
- shift || fail "Array name missing: array largest {name}"
+ shift || __sm.log.fail "Array name missing: array largest {name}"
__sm.array.largest "${_name}"
;;
(sort)
_subcommand="$1" _name="$2"
- shift 2 || fail "sort direction and array name missing;"\
+ shift 2 || __sm.log.fail "sort direction and array name missing;"\
" array sort <desc,asc> {name}."
__sm.array.sort "${_name}" "${_subcommand}"
;;
(unique)
_name="$1"
- shift || fail "Array name missing: array unique {name}."
+ shift || __sm.log.fail "Array name missing: array unique {name}."
__sm.array.unique "${_name}"
;;
(start)
echo ${__sm_array_start}
;;
(*)
- fail "Unknown array command '${_command}'"
+ __sm.log.fail "Unknown array command '${_command}'"
;;
esac
}
View
12 core/api/shell/command/functions
@@ -15,7 +15,7 @@ command()
;;
(is)
_subcommand="$1"
- shift || fail "A command must follow keyword 'is'; <function>"
+ shift || __sm.log.fail "A command must follow keyword 'is'; <function>"
case "${_subcommand}" in
(function)
if __sm.command.is.function "$1" >/dev/null 2>&1
@@ -24,20 +24,20 @@ command()
# (script)
# (binary)
(*)
- fail "Unknown command '${1}' following keyword 'is'"
+ __sm.log.fail "Unknown command '${1}' following keyword 'is'"
;;
esac
;;
(full)
_subcommand="$1"
- shift || fail "A 'command full' must follow keyword 'name'."
+ shift || __sm.log.fail "A 'command full' must follow keyword 'name'."
case "${_subcommand}" in
(name)
if __sm.command.full.name "$1" >/dev/null 2>&1
then return 0 ; else return 1 ; fi
;;
(*)
- shift || fail "A 'command full' must follow keyword 'name'."
+ shift || __sm.log.fail "A 'command full' must follow keyword 'name'."
;;
esac
;;
@@ -46,7 +46,7 @@ command()
(as)
shift
_user="$1"
- shift || fail "A user name or id must be specified after keyword 'as'"
+ shift || __sm.log.fail "A user name or id must be specified after keyword 'as'"
# TODO: Check to ensure user name/id exists on the system
if __sm.command.run.as "${_user}" "${_flags[*]}" "$@"
then return 0 ; else return 1 ; fi
@@ -60,7 +60,7 @@ command()
esac
;;
(*)
- fail "Unknown command '${_token}'."
+ __sm.log.fail "Unknown command '${_token}'."
;;
esac
done
View
24 core/api/shell/config/functions
@@ -15,44 +15,44 @@ config()
;;
(key)
_key="$1"
- shift || fail "a key must be given after keywords 'key'"
+ shift || __sm.log.fail "a key must be given after keywords 'key'"
;;
(value)
_value="$1"
- shift || fail "a value must be given after keywords 'value'"
+ shift || __sm.log.fail "a value must be given after keywords 'value'"
;;
(into|as)
_variable="$1"
- shift || fail "a variable name must be given after keywords 'into|as'"
+ shift || __sm.log.fail "a variable name must be given after keywords 'into|as'"
;;
(prefix) # TODO: Nix prefix?
_prefix="$1"
- shift || fail "a prefix name must be given after keyword 'prefix'"
+ shift || __sm.log.fail "a prefix name must be given after keyword 'prefix'"
;;
(file)
_file="$1"
- shift || fail "a file name must be given after keyword 'file'"
+ shift || __sm.log.fail "a file name must be given after keyword 'file'"
;;
(from)
- _extension="$1" || fail "An extension name must follow keyword 'for'"
+ _extension="$1" || __sm.log.fail "An extension name must follow keyword 'for'"
;;
esac
done
case "${_command}" in
(read)
- [[ -n "${_file}" ]] || fail "File name must be given (file {filename})."
- [[ -n "${_key}" ]] || fail "key name must be given (key {keyname})."
+ [[ -n "${_file}" ]] || __sm.log.fail "File name must be given (file {filename})."
+ [[ -n "${_key}" ]] || __sm.log.fail "key name must be given (key {keyname})."
__sm.config.read "${_extension}" "${_file}" "${_key}" "${_variable}" "${_prefix}"
;;
(write)
- [[ -n "${_file}" ]] || fail "File name must be given (file {filename})."
- [[ -n "${_key}" ]] || fail "key name must be given (key {keyname})."
- [[ -n "${_value}" ]] || fail "value must be given (value {valuename})."
+ [[ -n "${_file}" ]] || __sm.log.fail "File name must be given (file {filename})."
+ [[ -n "${_key}" ]] || __sm.log.fail "key name must be given (key {keyname})."
+ [[ -n "${_value}" ]] || __sm.log.fail "value must be given (value {valuename})."
__sm.config.write "${_extension}" "${_file}" "${_key}" "${_value}"
;;
(*)
- fail "Unknown command '${_command}'"
+ __sm.log.fail "Unknown command '${_command}'"
;;
esac
}
View
6 core/api/shell/database/extensions
@@ -4,9 +4,9 @@
database_extension_setup()
{
local extension="${1}" module="${2}" path="${3}"
- shift || fail "Extension must be given as the first parameter."
- shift || fail "Module must be given as the second parameter."
- shift || fail "Path must be given as the third parameter."
+ shift || __sm.log.fail "Extension must be given as the first parameter."
+ shift || __sm.log.fail "Module must be given as the second parameter."
+ shift || __sm.log.fail "Path must be given as the third parameter."
paths enter "${path}"
View
24 core/api/shell/date/functions
@@ -13,23 +13,23 @@ date()
case "${_token}" in
(step)
_step="${1:-}"
- shift || fail "step must follow keyword 'step'"
+ shift || __sm.log.fail "step must follow keyword 'step'"
;;
(format_in)
_format_in="${1}"
- shift || fail "input format must follow keyword 'format_in'"
+ shift || __sm.log.fail "input format must follow keyword 'format_in'"
;;
(format|format_out)
_format_out="${1}"
- shift || fail "output format must follow keyword 'format[_out]'"
+ shift || __sm.log.fail "output format must follow keyword 'format[_out]'"
;;
(start)
_start="${1}"
- shift || fail "start must follow keyword 'start'"
+ shift || __sm.log.fail "start must follow keyword 'start'"
;;
(end)
_end="${1}"
- shift || fail "end must follow keyword 'end'"
+ shift || __sm.log.fail "end must follow keyword 'end'"
;;
(*)
if [[ -z "${_start}" ]]
@@ -39,14 +39,14 @@ date()
then
_end="${_token}"
else
- fail "Unknown token '${_token}' passed as a parameter."
+ __sm.log.fail "Unknown token '${_token}' passed as a parameter."
fi
;;
esac
done
- [[ -n "${_start}" ]] || fail "start date must be specified."
- [[ -n "${_end}" ]] || fail "end date must be specified."
+ [[ -n "${_start}" ]] || __sm.log.fail "start date must be specified."
+ [[ -n "${_end}" ]] || __sm.log.fail "end date must be specified."
case "${_step}" in
minute)
@@ -68,23 +68,23 @@ date()
_step=31556926
;;
*)
- fail "Unknown step token ${1:-};"\
+ __sm.log.fail "Unknown step token ${1:-};"\
" valid steps are {minute,hour,day,week,month,year}."
;;
esac
_start=$(date -j -f "${_format_in}" ${_start} "+%s") ||
- fail "Date error: "\
+ __sm.log.fail "Date error: "\
" Input format '${_format_in}' for start date '${_start}'."
_end=$(date -j -f "${_format_in}" ${_end} "+%s") ||
- fail "Date error: "\
+ __sm.log.fail "Date error: "\
"Input format '${_format_in}' for end date '${_end}'."
while (( _start <= _end ))
do
_date=$(date -r ${_start} "+${_format_out}") ||
- fail "Date error: "\
+ __sm.log.fail "Date error: "\
"Output format '${_format_out}' for date '${_start}'."
printf "%s\n" "${_date}"
View
16 core/api/shell/extensions/functions
@@ -21,19 +21,19 @@ extension()
_command="${__sm_command_dotted}"
shift "${__sm_command_words}"
else
- fail "No command given.\nUsage: \nextension <command> ..."
+ __sm.log.fail "No command given.\nUsage: \nextension <command> ..."
fi
while (( $# ))
do
case "$1" in
(name|for|as)
_name=$2
- shift 2 || fail "Extension name was not given after <$1> param."
+ shift 2 || __sm.log.fail "Extension name was not given after <$1> param."
;;
(uri|from)
_uri=$2
- shift 2 || fail "Extension uri was not given after <$1> param."
+ shift 2 || __sm.log.fail "Extension uri was not given after <$1> param."
;;
(*)
_params+=( "$1" )
@@ -44,29 +44,29 @@ extension()
case "${_command}" in
(get.uri)
- [[ -n "${_name}" ]] || error "Extension name was not given for get uri."
+ [[ -n "${_name}" ]] || __sm.log.error "Extension name was not given for get uri."
if __sm.extension.get.uri "${_name}"
then return 0 ; else return $? ; fi
;;
(install)
- [[ -n "${_name}" ]] || error "Extension name was not given for install."
+ [[ -n "${_name}" ]] || __sm.log.error "Extension name was not given for install."
__sm.modules.include internal/extensions/manipulation
if __sm.extension.install "${_name}" "${_uri}"
then return 0 ; else return $? ; fi
;;
(search|find)
- [[ -n "${_name}" ]] || error "Extension name was not given for search."
+ [[ -n "${_name}" ]] || __sm.log.error "Extension name was not given for search."
if __sm.extension.in.paths __sm.extension.find "${_name}"
then
printf "${extensions_path}/${extension}\n"
else
- error "Extension '${_name}' not found!"
+ __sm.log.error "Extension '${_name}' not found!"
fi
;;
(extension.sets.iterator|extension.iterator)
__sm.extension.in.paths __sm.${_command} "${_params[@]}" || true
return 0
;;
- (*) error "Unknown command for extension '${_command}'."
+ (*) __sm.log.error "Unknown command for extension '${_command}'."
esac
}
View
46 core/api/shell/files/functions
@@ -35,20 +35,20 @@ files()
_command="${__sm_command_dotted}"
shift "${__sm_command_words}"
else
- fail "No command given.\nUsage: \nfiles <command> ..."
+ __sm.log.fail "No command given.\nUsage: \nfiles <command> ..."
fi
case "${_command}" in
(sha.*)
- command -v shasum > /dev/null 2>&1 || fail "shasum command missing, cannot use 'files sha'"
+ command -v shasum > /dev/null 2>&1 || __sm.log.fail "shasum command missing, cannot use 'files sha'"
;;
(chmod)
_mode="${1}"
- shift || fail "Mode must follow keywords 'chmod'"
+ shift || __sm.log.fail "Mode must follow keywords 'chmod'"
;;
(chown)
_owner="${1}"
- shift || fail "Owner must be provided after keyword 'owner'"
+ shift || __sm.log.fail "Owner must be provided after keyword 'owner'"
;;
esac
@@ -61,19 +61,19 @@ files()
;;
(to)
_target="${1}"
- shift || fail "Target path must be provided after keyword '${_token}'"
+ shift || __sm.log.fail "Target path must be provided after keyword '${_token}'"
;;
(from)
_source="${1}"
- shift || fail "Source path must be provided after keyword 'from'"
+ shift || __sm.log.fail "Source path must be provided after keyword 'from'"
;;
(mode|permissions)
_mode="${1}"
- shift || Fail "Mode must follow keywords 'mode|permissions'"
+ shift || __sm.log.fail "Mode must follow keywords 'mode|permissions'"
;;
(owner)
_owner="${1}"
- shift || fail "Owner must be provided after keyword 'owner'"
+ shift || __sm.log.fail "Owner must be provided after keyword 'owner'"
;;
(recursive|recursively)
_flags+=(-R)
@@ -87,27 +87,27 @@ files()
;;
(string|content)
_string="$1"
- shift || fail "A string must be followed by keyword 'string'"
+ shift || __sm.log.fail "A string must be followed by keyword 'string'"
;;
(regex)
_regex="$1"
- shift || fail "A regex must be followed by keyword 'regex'"
+ shift || __sm.log.fail "A regex must be followed by keyword 'regex'"
;;
(in)
_files+=("$1")
- shift || fail "A file name must follow keyword 'in'"
+ shift || __sm.log.fail "A file name must follow keyword 'in'"
;;
(key)
_key="$1"
- shift || fail "A key name must follow keyword 'key'"
+ shift || __sm.log.fail "A key name must follow keyword 'key'"
;;
(value)
_value="$1"
- shift || fail "A value must follow keyword 'value'"
+ shift || __sm.log.fail "A value must follow keyword 'value'"
;;
(with)
_string="$1"
- shift || fail "A content string must follow keyword 'with'"
+ shift || __sm.log.fail "A content string must follow keyword 'with'"
;;
(*)
_files+=("${_token}")
@@ -125,42 +125,42 @@ files()
then return 0 ; else return 1 ; fi
;;
(open|md5|enter|join|expand|search|within|in|source|empty|nonempty|exist|exists|remove|create)
- [[ -n "${_files}" ]] || fail "files must be given for 'files ${_command}'."
+ [[ -n "${_files}" ]] || __sm.log.fail "files must be given for 'files ${_command}'."
if __sm.files.${_command} "${_files[@]}"
then return 0 ; else return 1 ; fi
;;
(link)
[[ -e "${_source}" ]] ||
- fail "Cannot link ${_source} to ${_target}, source does not exist!"
+ __sm.log.fail "Cannot link ${_source} to ${_target}, source does not exist!"
if [[ -f "${_target}" ]] && ! __sm.string.contains "-f" "${_flags[*]}"
then
- fail "Cannot link ${_source} to ${_target} which exists as a file!"
+ __sm.log.fail "Cannot link ${_source} to ${_target} which exists as a file!"
fi
if [[ -d "${_target}" ]] && ! __sm.string.contains "-f" "${_flags[*]}"
then
- fail "Cannot link ${_source} to ${_target} which exists as a directory"
+ __sm.log.fail "Cannot link ${_source} to ${_target} which exists as a directory"
fi
#TODO: what about the -f (force flag) to overwrite if target exists ?
__sm.files.link "${_source}" "${_target}" "${_flags[*]}"
;;
(copy|move)
if [[ -n "${_files[*]}" ]]
then
- [[ -n "${_source}" || -n "${_target}" ]] || fail "Source or target path (to/from) for ${_command}ing files must be given."
+ [[ -n "${_source}" || -n "${_target}" ]] || __sm.log.fail "Source or target path (to/from) for ${_command}ing files must be given."
else
- [[ -n "${_source}" && -n "${_target}" ]] || fail "Source and target path (to/from) for ${_command}ing file must be given."
+ [[ -n "${_source}" && -n "${_target}" ]] || __sm.log.fail "Source and target path (to/from) for ${_command}ing file must be given."
fi
__sm.files.${_command} "${_source:-.}" "${_target:-.}" "${_flags[*]}" "${_files[@]}"
;;
(write)
- [[ -n "${_string}" ]] || fail "String must be given; string 'string'."
- [[ -n "${_target}" ]] || fail "Target must be given; to {file name}."
+ [[ -n "${_string}" ]] || __sm.log.fail "String must be given; string 'string'."
+ [[ -n "${_target}" ]] || __sm.log.fail "Target must be given; to {file name}."
__sm.files.write "${_string}" "${_target}" "${_flags[*]}"
;;
(*)
if [[ -z "${_owner}" && -z "${_mode}" ]]
then
- fail "Unknown command for files: '${_command}' "\
+ __sm.log.fail "Unknown command for files: '${_command}' "\
"A files command must be specified as the first parameter: "\
"{chown,chmod,create,remove,copy,in,search,enter,exist,join,expand,move,copy}"
fi
View
10 core/api/shell/hash/functions
@@ -18,11 +18,11 @@ hash()
;;
(key)
_key="$1"
- shift || fail "Key name must follow keyword 'key'"
+ shift || __sm.log.fail "Key name must follow keyword 'key'"
;;
(variable)
_variable="$1"
- shift || fail "Variable name must follow keyword 'variable'"
+ shift || __sm.log.fail "Variable name must follow keyword 'variable'"
;;
(*)
if [[ -z "${_command}" ]]
@@ -37,13 +37,13 @@ hash()
case "${_command}" in
(keys)
- [[ -n "${_file}" ]] || fail " Filename not given."
+ [[ -n "${_file}" ]] || __sm.log.fail " Filename not given."
echo -n $(grep -E "${_valid_keys}=" "${_file}" | grep -Eo "${_valid_keys}")
;;
(read)
# Read value from given file($1) for given key($2), and assign it to a variable($3).
- [[ -n "${_file}" ]] || fail "Filename was not given (from '{filename}')."
- [[ -n "${_key}" ]] || fail "Key name was not given (key '{key}')."
+ [[ -n "${_file}" ]] || __sm.log.fail "Filename was not given (from '{filename}')."
+ [[ -n "${_key}" ]] || __sm.log.fail "Key name was not given (key '{key}')."
if [[ -n "${_variable}" ]]
then
View
6 core/api/shell/help/functions
@@ -98,7 +98,7 @@ show_help()
description()
{
local _description="$*"
- shift || fail "Cannot add description to help; description given."
+ shift || __sm.log.fail "Cannot add description to help; description given."
help_descriptions+=("$*")
}
@@ -192,8 +192,8 @@ help_description()
action()
{
local _name="${1:-}" _description="${2:-}"
- shift || fail "An action name must be provided:\naction {name} {description}."
- shift || fail "An description must be provided:\naction {name} {description}."
+ shift || __sm.log.fail "An action name must be provided:\naction {name} {description}."
+ shift || __sm.log.fail "An description must be provided:\naction {name} {description}."
help_action_names+=( "${_name}" )
help_action_descriptions+=( "${_description}" )
View
4 core/api/shell/interactive/functions
@@ -9,13 +9,13 @@ shell()
(is)
_command=is
_subcommand="${1}"
- shift || fail "A command must follow keyword 'is'"
+ shift || __sm.log.fail "A command must follow keyword 'is'"
case "${_subcommand}" in
(interactive)
[[ -t 0 ]]
;;
(*)
- fail "Unknown command following keyword 'is'; shell is <interactive>"
+ __sm.log.fail "Unknown command following keyword 'is'; shell is <interactive>"
;;
esac
(*)
View
10 core/api/shell/logging/functions
@@ -24,7 +24,7 @@ api_logging_initialize()
logrotate()
{
local _file="${1:-}"
- shift || fail "Cannot rotate a log file, as no log file was given."
+ shift || __sm.log.fail "Cannot rotate a log file, as no log file was given."
verbose "Tailing the file in a background process into a tail logfile."
( tail -n 0 -f "${_file}" > ${file}.$$.log )&
@@ -88,19 +88,19 @@ log_streams()
;;
err)
_stderr="${1}"
- shift || fail "stderr name must follow keyword 'err'"
+ shift || __sm.log.fail "stderr name must follow keyword 'err'"
;;
out)
_stdout="${1}"
- shift || fail "stdout name must follow keyword 'out'"
+ shift || __sm.log.fail "stdout name must follow keyword 'out'"
;;
mix)
_stdmix="${1}"
- shift || fail "stdmix name must follow keyword 'mix'"
+ shift || __sm.log.fail "stdmix name must follow keyword 'mix'"
;;
*)
_command="${1}"
- shift || fail "A command must be given in order to log it's streams."
+ shift || __sm.log.fail "A command must be given in order to log it's streams."
;;
esac
done
View
14 core/api/shell/os/functions
@@ -22,19 +22,19 @@ os()
(is)
_command="$token"
_os="${1}"
- shift || fail "lowercase operating system name must follow keyword 'os';"\
+ shift || __sm.log.fail "lowercase operating system name must follow keyword 'os';"\
"os is <linux|darwin|bsd|solaris|aix>"
;;
(cpu)
_command=cpu
_subcommand="$1"
- shift || fail "A command must follow keyword 'cpu'; one of {count}"
+ shift || __sm.log.fail "A command must follow keyword 'cpu'; one of {count}"
case "${_subcommand}" in
(count)
true # all good.
;;
(*)
- fail "A valid command must follow keyword 'cpu'; one of {count}"
+ __sm.log.fail "A valid command must follow keyword 'cpu'; one of {count}"
;;
esac
;;
@@ -61,7 +61,7 @@ os()
fi
;;
(*)
- fail "Unhandled os '${_os}'"
+ __sm.log.fail "Unhandled os '${_os}'"
;;
esac
;;
@@ -103,12 +103,12 @@ os()
__sm.os.cpu.count
;;
(*)
- fail "Unknown command for os cpu: '${_subcommand}'; valid commands include {count} "
+ __sm.log.fail "Unknown command for os cpu: '${_subcommand}'; valid commands include {count} "
;;
esac
;;
(*)
- fail "Unknown command for os: '${_command}' "\
+ __sm.log.fail "Unknown command for os: '${_command}' "\
"A os command must be specified as the first parameter: "\
"{is,}"
;;
@@ -132,7 +132,7 @@ init_scripts_path()
then
printf "/etc/rc.d"
else
- fail "Unknown init scripts directory (/etc/init.d or /etc/rc.d not found)."
+ __sm.log.fail "Unknown init scripts directory (/etc/init.d or /etc/rc.d not found)."
fi
;;
esac
View
6 core/api/shell/package/extensions
@@ -3,9 +3,9 @@
package_extension_setup()
{
local extension="${1:-}" module="${2:-}" path="${3:-}" ${language:=shell}
- shift || fail "No extension name given."
- shift || fail "No module name given."
- shift || fail "No path given."
+ shift || __sm.log.fail "No extension name given."
+ shift || __sm.log.fail "No module name given."
+ shift || __sm.log.fail "No path given."
for action in install uninstall update activate deactivate
do
View
40 core/api/shell/package/functions
@@ -57,21 +57,21 @@ package()
shift
;;
(*)
- fail "A valid command must follow keyword is; {active|installed}"
+ __sm.log.fail "A valid command must follow keyword is; {active|installed}"
;;
esac
;;
(log)
_log="$1"
- shift || fail "Log file path/name must be given following keyword 'log'"
+ shift || __sm.log.fail "Log file path/name must be given following keyword 'log'"
;;
(lines)
_lines="$1"
- shift || fail "Number of lines to show must be given following keyword 'lines'"
+ shift || __sm.log.fail "Number of lines to show must be given following keyword 'lines'"
;;
(message)
_message="$1"
- shift || fail "Message must be given following keyword 'message'"
+ shift || __sm.log.fail "Message must be given following keyword 'message'"
;;
(configure)
_command=configure
@@ -81,7 +81,7 @@ package()
shift
;;
(*)
- fail "Unknown configure param '$1'."
+ __sm.log.fail "Unknown configure param '$1'."
continue
;;
esac
@@ -112,43 +112,43 @@ package()
;;
(key)
_key="$1"
- shift || fail "Key name must follow keyword 'key'"
+ shift || __sm.log.fail "Key name must follow keyword 'key'"
;;
(name)
package_name="$1"
- shift || fail "a package name must follow keyword 'name'"
+ shift || __sm.log.fail "a package name must follow keyword 'name'"
;;
(version)
package_version="$1"
- shift || fail "a package version must follow keyword 'version'"
+ shift || __sm.log.fail "a package version must follow keyword 'version'"
;;
(base_url)
package_base_url="$1"
- shift || fail "a package base_url must follow keyword 'base_url'"
+ shift || __sm.log.fail "a package base_url must follow keyword 'base_url'"
;;
(file)
package_file="$1"
- shift || fail "a package file name must follow keyword 'file'"
+ shift || __sm.log.fail "a package file name must follow keyword 'file'"
;;
(user)
package_user="$1"
- shift || fail "a package user name must follow keyword 'user'"
+ shift || __sm.log.fail "a package user name must follow keyword 'user'"
;;
(archive_format)
archive_format="$1"
- shift || fail "a package archive_format must follow keyword 'archive_format'"
+ shift || __sm.log.fail "a package archive_format must follow keyword 'archive_format'"
;;
(md5)
package_md5="$1"
- shift || fail "a package md5 sum must follow keyword 'md5'"
+ shift || __sm.log.fail "a package md5 sum must follow keyword 'md5'"
;;
(sha256)
package_sha256="$1"
- shift || fail "a package sha256 key must follow keyword 'sha256'"
+ shift || __sm.log.fail "a package sha256 key must follow keyword 'sha256'"
;;
(sha512)
package_sha512="$1"
- shift || fail "a package sha512 key must follow keyword 'sha512'"
+ shift || __sm.log.fail "a package sha512 key must follow keyword 'sha512'"
;;
(*)
_params+=("${_token}")
@@ -158,7 +158,7 @@ package()
true ${package_name:=${extension}}
- [[ -n "${package_name}" ]] || fail "Package name must be set/given"
+ [[ -n "${package_name}" ]] || __sm.log.fail "Package name must be set/given"
case "${_command}" in
(make)
@@ -195,12 +195,12 @@ package()
esac
;;
(define)
- [[ -n "${_params}" ]] || fail "No '{key} {value}' pairs given."
+ [[ -n "${_params}" ]] || __sm.log.fail "No '{key} {value}' pairs given."
if array is even _params
then
__sm.package.define "${_params[@]}"
else
- fail "Every key must have an associated value."
+ __sm.log.fail "Every key must have an associated value."
fi
;;
(activate)
@@ -217,14 +217,14 @@ package()
__sm.package.init
;;
(error)
- [[ -n "${_message}" ]] || fail "Message must be given for package error."
+ [[ -n "${_message}" ]] || __sm.log.fail "Message must be given for package error."
__sm.package.error "${_params[@]}" "${_log}" "${_lines}"
;;
(cli)
__sm.package.cli "${_params[@]}"
;;
(*)
- fail "Unknown package command '${_token}'"
+ __sm.log.fail "Unknown package command '${_token}'"
esac
}
View
44 core/api/shell/paths/functions
@@ -62,17 +62,17 @@ paths()
_command="${__sm_command_dotted}"
shift "${__sm_command_words}"
else
- fail "No command given.\nUsage: \npaths <command> ..."
+ __sm.log.fail "No command given.\nUsage: \npaths <command> ..."
fi
case "${_command}" in
(chmod)
_mode="${1}"
- shift || fail "Mode must follow keywords 'chmod'"
+ shift || __sm.log.fail "Mode must follow keywords 'chmod'"
;;
(chown)
_owner="${1}"
- shift || fail "Owner must be provided after keyword 'owner'"
+ shift || __sm.log.fail "Owner must be provided after keyword 'owner'"
;;
esac
@@ -82,31 +82,31 @@ paths()
case "${_token}" in
(to)
_target="${1}"
- shift || fail "Target path must be given after keyword 'to'"
+ shift || __sm.log.fail "Target path must be given after keyword 'to'"
;;
(from)
_source="${1}"
- shift || fail "Source path must be given after keyword 'from'"
+ shift || __sm.log.fail "Source path must be given after keyword 'from'"
;;
(mode|permissions)
_mode="${1}"
- shift || Fail "Mode must follow keyword '${_token}'"
+ shift || __sm.log.fail "Mode must follow keyword '${_token}'"
;;
(owner)
_owner="${1}"
- shift || fail "Owner must be given after keyword 'owner'"
+ shift || __sm.log.fail "Owner must be given after keyword 'owner'"
;;
(recursive|recursively)
_flags+=(-R)
;;
(matching|regex|glob)
_regex="$1"
shift ||
- fail "Shell glob pattern string must b given after keyword '${_token}'"
+ __sm.log.fail "Shell glob pattern string must b given after keyword '${_token}'"
;;
(in)
_paths+=("$1")
- shift || fail "A path is expected following keyword 'in'"
+ shift || __sm.log.fail "A path is expected following keyword 'in'"
;;
(*)
_paths+=("${_token}")
@@ -116,43 +116,43 @@ paths()
case "${_command}" in
(chown)
- [[ -n "${_owner}" ]] || fail "'identity {user}[:{group}]' was not given."
- [[ -n "${_paths}" ]] || fail "Paths must be given."
+ [[ -n "${_owner}" ]] || __sm.log.fail "'identity {user}[:{group}]' was not given."
+ [[ -n "${_paths}" ]] || __sm.log.fail "Paths must be given."
__sm.paths.chown "${_owner}" "${_flags[*]}" "${_paths[@]}"
;;
(chmod)
- [[ -n "${_mode}" ]] || fail "'mode {file mode}' must be given."
- [[ -n "${_paths}" ]] || fail "Paths to chmod must be given."
+ [[ -n "${_mode}" ]] || __sm.log.fail "'mode {file mode}' must be given."
+ [[ -n "${_paths}" ]] || __sm.log.fail "Paths to chmod must be given."
__sm.paths.chmod "${_mode}" "${_flags[*]}" "${_paths[@]}"
;;
(search)
- [[ -n "${_paths}" ]] || fail "Path to search paths under must be given."
- [[ -n "${_glob}" ]] || fail "Glob pattern was not given (matches {glob})."
+ [[ -n "${_paths}" ]] || __sm.log.fail "Path to search paths under must be given."
+ [[ -n "${_glob}" ]] || __sm.log.fail "Glob pattern was not given (matches {glob})."
__sm.paths.search "${_regex}" "${_paths}"
;;
(in)
- [[ -n "${_paths}" ]] || fail "Path to list paths in must be given."
+ [[ -n "${_paths}" ]] || __sm.log.fail "Path to list paths in must be given."
__sm.paths.in "${_paths[@]}"
;;
(absolute)
- [[ -n "${_paths}" ]] || fail "Path to expand must be given."
+ [[ -n "${_paths}" ]] || __sm.log.fail "Path to expand must be given."
__sm.paths.absolute "${_paths[@]}"
;;
(create|remove|enter|exists|join|expand)
- [[ -n "${_paths}" ]] || fail "Path to ${_command} must be given."
+ [[ -n "${_paths}" ]] || __sm.log.fail "Path to ${_command} must be given."
__sm.paths.${_command} "${_paths[@]}"
;;
(copy)
- [[ -n "${_target}" ]] || fail "Target path (to) for copying into must be given."
+ [[ -n "${_target}" ]] || __sm.log.fail "Target path (to) for copying into must be given."
__sm.paths.copy "${_target}" "${_flags[*]}" "${_paths[@]}"
;;
(move)
- [[ -n "${_source}" ]] || fail "Source must be given to ${_command} (from x)."
- [[ -n "${_target}" ]] || fail "Target must be given to ${_command} (to y)."
+ [[ -n "${_source}" ]] || __sm.log.fail "Source must be given to ${_command} (from x)."
+ [[ -n "${_target}" ]] || __sm.log.fail "Target must be given to ${_command} (to y)."
__sm.paths.move "${_source}" "${_target}"
;;
(*)
- fail "Unknown command for paths: '${_command}' "\
+ __sm.log.fail "Unknown command for paths: '${_command}' "\
"A paths command must be specified as the first parameter: "\
"{chown,chmod,create,remove,copy,in,search,enter,exist,join,expand,move,copy}"
;;
View
6 core/api/shell/service/extensions
@@ -3,9 +3,9 @@
service_extension_setup()
{
local extension="${1}" module="${2}" path="${3}" ${language:=shell}
- shift || fail "Extension name not given as first parameter."
- shift || fail "Module name not given as second parameter."
- shift || fail "Path not given as third parameter."
+ shift || __sm.log.fail "Extension name not given as first parameter."
+ shift || __sm.log.fail "Module name not given as second parameter."
+ shift || __sm.log.fail "Path not given as third parameter."
for action in start stop restart status list
do
View
2 core/api/shell/steps/functions
@@ -6,7 +6,7 @@ step()
{
local name="$1"
- shift || fail "Cannot take step as no step name given;"\
+ shift || __sm.log.fail "Cannot take step as no step name given;"\
"step [name] <- missing name."
start_step "$name"
View
6 core/api/shell/string/functions
@@ -14,15 +14,15 @@ string()
case "${_token}" in
(from)
_search="$1"
- shift || fail "From source string must follow keyword 'from'"
+ shift || __sm.log.fail "From source string must follow keyword 'from'"
;;
(to)
_string="$1"
;;
(contains)
_command=contains
_search="$1"
- shift || fail "Search (glob) string must follow keyword 'contains'"
+ shift || __sm.log.fail "Search (glob) string must follow keyword 'contains'"
;;
(*)
if [[ -z "${_string}" ]]
@@ -59,7 +59,7 @@ string()
printf ""
;;
(*)
- fail "Unknown string command '${_command}'"
+ __sm.log.fail "Unknown string command '${_command}'"
;;
esac
}
View
24 core/api/shell/templates/functions
@@ -35,32 +35,32 @@ templates()
_command="${__sm_command_dotted}"
shift "${__sm_command_words}"
else
- fail "No command given.\nUsage: \npaths <command> ..."
+ __sm.log.fail "No command given.\nUsage: \npaths <command> ..."
fi
_name="$1"
- shift || fail "Template name was not given"
+ shift || __sm.log.fail "Template name was not given"
while (( $# > 0 ))
do
_token="${1}" && shift
case "${_token}" in
- to)
+ (to)
_target="$1"
- shift || fail "target path must follow keyword 'to'"
+ shift || __sm.log.fail "target path must follow keyword 'to'"
;;
- mode)
+ (mode)
_mode="$1"
- shift || fail "mode must follow keyword 'mode'"
+ shift || __sm.log.fail "mode must follow keyword 'mode'"
;;
- owner)
+ (owner)
_owner="$1"
- shift || fail "owner must follow keyword 'owner'"
+ shift || __sm.log.fail "owner must follow keyword 'owner'"
;;
- from)
- fail "'from' keyword is no longer supported"
+ (from)
+ __sm.log.fail "'from' keyword is no longer supported"
;;
- *)
+ (*)
_params+=("${_token}")
esac
done
@@ -70,7 +70,7 @@ templates()
__sm.templates.${_command} "${_name}" "${_params[@]}"
;;
(*)
- fail "Unknown command '${_command}' for templates API."
+ __sm.log.fail "Unknown command '${_command}' for templates API."
;;
esac
}
View
6 core/api/shell/time/functions
@@ -16,14 +16,14 @@ timestamp()
_command="${__sm_command_dotted}"
shift "${__sm_command_words}"
else
- fail "No command given.\nUsage:\n timestamp <command> ..."
+ __sm.log.fail "No command given.\nUsage:\n timestamp <command> ..."
fi
case "${_command}" in
(show.new|show.current|set)
if __sm.timestamp.${_command}
then return 0 ; else return $? ; fi
;;
- (*) error "Unknown command for extension '${_command}'."
+ (*) __sm.log.error "Unknown command for extension '${_command}'."
esac
-}
+}
View
8 core/api/shell/traps/functions
@@ -15,11 +15,11 @@ traps()
case "${_token}" in
(on)
_signal="$1"
- shift || fail "A signal must follow keyword 'on'"
+ shift || __sm.log.fail "A signal must follow keyword 'on'"
case "${_signal}" in
(exit|EXIT)
_code="$*"
- shift || fail "The code to be run on EXIT must be given after keyword 'EXIT'."
+ shift || __sm.log.fail "The code to be run on EXIT must be given after keyword 'EXIT'."
__traps_code="$(trap)"
__traps_code="$( echo "${__traps_code}" | awk '/ EXIT$/' |
sed -e "s#' EXIT##" -e "s#.*'##")"
@@ -35,11 +35,11 @@ traps()
__sm_traps_exit_commands+=( "${_code}" )
;;
(*)
- fail "Unknown signal '${_signal}'"
+ __sm.log.fail "Unknown signal '${_signal}'"
;;
esac
(*)
- fail "_unknown command "${_token}
+ __sm.log.fail "_unknown command "${_token}
;;
esac
done
View
20 core/api/shell/user/functions
@@ -22,23 +22,23 @@ user()
_command="${__sm_command_dotted}"
shift "${__sm_command_words}"
else
- fail "No command given.\nUsage: \nextension <command> ..."
+ __sm.log.fail "No command given.\nUsage: \nextension <command> ..."
fi
case "${_command}" in
(set.home)
_value="$1"
- shift || fail "A home path must follow keyword 'home';"\
+ shift || __sm.log.fail "A home path must follow keyword 'home';"\
"user set home /home/{username} for {username}"
;;
(set.shell)
_value="$1"
- shift || fail "A shell must follow keyword 'shell'"\
+ shift || __sm.log.fail "A shell must follow keyword 'shell'"\
"user set shell /bin/zsh for {username}"
;;
(exists)
_user="$1"
- shift || fail "A user name must follow keyword 'exists'"\
+ shift || __sm.log.fail "A user name must follow keyword 'exists'"\
"user exists {username}"
;;
esac
@@ -52,25 +52,25 @@ user()
;;
(name|user|for)
_user="$1"
- shift || fail "User name must follow keyword 'user'"
+ shift || __sm.log.fail "User name must follow keyword 'user'"
;;
(group)
_group="${1:-}"
- shift || fail "Group name must follow keyword 'group'"
+ shift || __sm.log.fail "Group name must follow keyword 'group'"
;;
(from)
_source="${1:-}"
- shift || fail "from source name must follow keyword 'from'"
+ shift || __sm.log.fail "from source name must follow keyword 'from'"
;;
(shell)
_shell="${1:-}"
- shift || fail "A user shell (/bin/{zsh,bash}) must follow keyword 'shell'"
+ shift || __sm.log.fail "A user shell (/bin/{zsh,bash}) must follow keyword 'shell'"
;;
(force)
_flags+=(-f)
;;
(*)
- fail "Unhandled token '${_token}'"
+ __sm.log.fail "Unhandled token '${_token}'"
;;
esac
done
@@ -95,7 +95,7 @@ user()
__sm.user.${_command} "${_user}" "${_flags[*]}"
;;
(*)
- fail "Unknown command '${_command}'"
+ __sm.log.fail "Unknown command '${_command}'"
;;
esac
}
View
14 core/api/shell/variables/functions
@@ -19,7 +19,7 @@ variables()
_command="${__sm_command_dotted}"
shift "${__sm_command_words}"
else
- fail "No command given.\nUsage: \nvariables <command> ..."
+ __sm.log.fail "No command given.\nUsage: \nvariables <command> ..."
fi
while (( $# ))
@@ -32,11 +32,11 @@ variables()
shift 2
;;
("")
- fail "Variable output type was not given after 'type'. " \
+ __sm.log.fail "Variable output type was not given after 'type'. " \
"Valid types are: log, error, fail"
;;
(*)
- fail "Variable output type '$2' in not valid. " \
+ __sm.log.fail "Variable output type '$2' in not valid. " \
"Valid types are: log, error, fail"
;;
esac
@@ -51,16 +51,16 @@ variables()
# TODO: Think through variables more...
case "${_command}" in
(are.empty|are.nonempty)
- [[ -n "${_variables[*]}" ]] || error "No variable names given for validation"
+ [[ -n "${_variables[*]}" ]] || __sm.log.error "No variable names given for validation"
__sm.variables.${_command} "${_variables[@]}"
;;
(must.be.empty|must.be.nonempty)
- [[ -n "${_variables[*]}" ]] || error "No variable names given for validation"
- [[ -n "${_type}" ]] || error "No message type given for validation"
+ [[ -n "${_variables[*]}" ]] || __sm.log.error "No variable names given for validation"
+ [[ -n "${_type}" ]] || __sm.log.error "No message type given for validation"
__sm.variables.${_command} "${_type}" "${_variables[@]}"
;;
(*)
- fail "Unknown variables command '${_command}'"
+ __sm.log.fail "Unknown variables command '${_command}'"
;;
esac
}
View
2 core/cli/bin/call
@@ -7,5 +7,5 @@ elif __sm.command.is.function "${extension_args[${__sm_array_start}]}" >/dev/nul
then
"${extension_args[@]}"
else
- error "${extension_args[${__sm_array_start}]} is not a valid function name."
+ __sm.log.error "${extension_args[${__sm_array_start}]} is not a valid function name."
fi
View
10 core/cli/bin/clone
@@ -4,7 +4,7 @@ NYI
# extension_is_installed removed, as it was not working already.
[[ -n "${extension_args}" ]] ||
- error "clone: An extension name must be specified."
+ __sm.log.error "clone: An extension name must be specified."
for (( index = 0 ; index < ${#extension_args[@]} ; index++ ))
do
@@ -32,17 +32,17 @@ done
# Sanity checks.
[[ -n "${_source}" ]] ||
- error "clone: A source extension name must be specified."
+ __sm.log.error "clone: A source extension name must be specified."
[[ -n "${_target}" ]] ||
- error "clone: A target extension name must be specified."
+ __sm.log.error "clone: A target extension name must be specified."
extension_is_installed "${_source}" ||
- error "clone: The extension '${_source}' was not found installed; "\
+ __sm.log.error "clone: The extension '${_source}' was not found installed; "\
"cannot create a new extension from it."
! extension_is_installed "${_target}" ||
- error "clone: The target extension '${_target}' already exists; "\
+ __sm.log.error "clone: The target extension '${_target}' already exists; "\
"cannot create it from ${_source}."
path copy \
View
4 core/cli/bin/console
@@ -3,7 +3,7 @@
shell_version=( $( ${user_shell} --version | head -n 1 ) )
[[ "${shell_version[1]}" == "bash," ]] && (( ${BASH_VERSINFO[0]} > 3 )) ||
- error "console: Unsuported shell:\n ${shell_version[*]}\n\nUse bash 4 for console\n"
+ __sm.log.error "console: Unsuported shell:\n ${shell_version[*]}\n\nUse bash 4 for console\n"
trap - ERR
${user_shell} --rcfile <(echo "
@@ -14,7 +14,7 @@ ${user_shell} --rcfile <(echo "
fail() { backtrace \"\$*\" no_exit ; }
error() { printf \"\\nERROR: \$*\\n\" >&2 ; }
exit() { builtin exit 0 ; }
- trap \"backtrace \\\"A command has returned error code (\\\$?) without being handled.\\\" no_exit\" ERR
+ trap \"backtrace \\\"A command has returned __sm.log.error code (\\\$?) without being handled.\\\" no_exit\" ERR
export PS1='(sm) [ret=\$?] \w > '
") -i
View
6 core/cli/bin/dev/create
@@ -1,20 +1,20 @@
#!/bin/sh
[[ -n "${extension_args}" ]] ||
- fail "create: You must specify at least one extension name."
+ __sm.log.fail "create: You must specify at least one extension name."
target_path="${extensions_development_path:-"$initial_pwd"}"
for extension in ${extension_args[@]}
do
if paths exists "${target_path}/${extension}"
then
- error "create: Extension '${extension}' already exists "\
+ __sm.log.error "create: Extension '${extension}' already exists "\
"at ${target_path}/${extension}."
fi
paths exists "${sm_path}/core/cli/templates/api/" ||
- fail "create: Extension template files are missing from "\
+ __sm.log.fail "create: Extension template files are missing from "\
"$target_path/core/cli/templates/api/"
paths enter "${sm_path}/core/cli/templates/api/"
View
2 core/cli/bin/dev/package
@@ -1,7 +1,7 @@
#!/bin/sh
[[ -n "${extension_args}" ]] ||
- error "package: You must specify at least one extension name for packaging."
+ __sm.log.error "package: You must specify at least one extension name for packaging."
for extension in "${extension_args[@]}"
do
View
2 core/cli/bin/dev/publish
@@ -1,7 +1,7 @@
#!/bin/sh
(( ${#extension_args[@]} )) ||
- error "publish: You must specify at least one extension name for packaging."
+ __sm.log.error "publish: You must specify at least one extension name for packaging."
for extension in "${extension_args[@]}"
do
View
2 core/cli/bin/module_utils/edit
@@ -9,7 +9,7 @@ then # edit core
exec ${EDITOR:-vi} .
else # edit extension
paths exists "${extensions_development_path}/${extension_args[${__sm_array_start}]}" ||
- error \
+ __sm.log.error \
"Failed to edit '${extension_args[${__sm_array_start}]}'; it appears to not be installed."\
"To see installed extensions, run:\n sm list"
View
2 core/cli/bin/module_utils/open
@@ -1,7 +1,7 @@
#!/bin/sh
[[ -n "${extension_args}" ]] ||
- fail "open: You must specify at least one extension name."
+ __sm.log.fail "open: You must specify at least one extension name."
paths enter "${extensions_development_path}/${extension_args[${__sm_array_start}]}/"
View
2 core/cli/bin/module_utils/src
@@ -1,7 +1,7 @@
#!/bin/sh
[[ -n "${extension_args}" ]] ||
- fail "src: You must specify at least one extension name."
+ __sm.log.fail "src: You must specify at least one extension name."
printf "${extensions_development_path}/${extension_args[${__sm_array_start}]}/"
View
4 core/cli/bin/open
@@ -1,10 +1,10 @@
#!/bin/sh
[[ -n "${extension_args}" ]] ||
- fail "open: You must specify at least one extension name."
+ __sm.log.fail "open: You must specify at least one extension name."
path exists "${extensions_development_path}/${extension_args[${__sm_array_start}]}" ||
- error "open: Failed to open '${extension_args[${__sm_array_start}]}'; it appears to not be installed."
+ __sm.log.error "open: Failed to open '${extension_args[${__sm_array_start}]}'; it appears to not be installed."
os open "${extensions_development_path}/${extension_args[${__sm_array_start}]}"
View
4 core/cli/bin/src
@@ -1,13 +1,13 @@
#!/bin/sh
[[ -n "${extension_args}" ]] ||
- fail "src: You must specify at least one extension name."
+ __sm.log.fail "src: You must specify at least one extension name."
if paths exists "${extensions_development_path}/${extension_args[${__sm_array_start}]}"
then
printf "${extensions_development_path}/${extension_args[${__sm_array_start}]}"
else
printf "." # Stay put!
- error "Failed to edit '${extension_args[${__sm_array_start}]}'; it appears to not be installed."
+ __sm.log.error "Failed to edit '${extension_args[${__sm_array_start}]}'; it appears to not be installed."
fi
View
8 core/cli/bin/version
@@ -3,10 +3,10 @@
sm_version
case "${extension_args[${__sm_array_start}]}" in
- -v|-V) # Only echo version information.
- succeed "${sm_version:-"?.?.?"}"
+ (-v|-V) # Only echo version information.
+ __sm.log.succeed "${sm_version:-"?.?.?"}"
;;
- *) # GNU-style extended version information.
- succeed "\nSM Framework ${sm_version:-"?.?.?"} https://sm.beginrescueend.com/ by Wayne E. Seguin (wayneeseguin@gmail.com)\n"
+ (*) # GNU-style extended version information.
+ __sm.log.succeed "\nSM Framework ${sm_version:-"?.?.?"} https://sm.beginrescueend.com/ by Wayne E. Seguin (wayneeseguin@gmail.com)\n"
;;
esac
View
2 core/cli/bin/website
@@ -1,7 +1,7 @@
#!/bin/sh
[[ -n "${extension_args}" ]] ||
- fail "website: You must specify at least one extension name."
+ __sm.log.fail "website: You must specify at least one extension name."
paths enter "${extensions_development_path}/${extension_args[${__sm_array_start}]}/"
View
18 core/cli/shell/dev/functions
@@ -67,7 +67,7 @@ sm_development_setup()
# TODO: Switch to using fetch_uri here.
git clone ${_url} ${_component} ||
- error "There was an error cloning ${_component} repository from ${_url} into ${PWD}/${_component}."
+ __sm.log.error "There was an __sm.log.error cloning ${_component} repository from ${_url} into ${PWD}/${_component}."
log " * ${_component} repository successfully cloned into $PWD/${_component}/."
fi
@@ -84,15 +84,15 @@ sm_development_update()
extension_package()
{
local _name="${1:-}" _path _version file _archiver
- shift || fail "Cannot package an extension; no extension name was given."
+ shift || __sm.log.fail "Cannot package an extension; no extension name was given."
_path="${extensions_development_path:-"$extensions_src_path"}"
paths create "${_path}"
paths enter "${_path}"
__sm.extension.is.valid "${_path}/${_name}" ||
- error "Cannot package extension '${_name}'; the extension is not valid."
+ __sm.log.error "Cannot package extension '${_name}'; the extension is not valid."
_version="$(cat "${_name}/VERSION")"
log "Packaging extension ${_name}"
@@ -103,7 +103,7 @@ extension_package()
if command exists ${_archiver// *}
then
tar cf "${_name}-${_version}.tar" "${_name}/" ||
- error "Error during packaging ($?) whilst trying to create a tar of the '${_name}' directory."
+ __sm.log.error "Error during packaging ($?) whilst trying to create a tar of the '${_name}' directory."
${_archiver} -f -9 "${_name}-${_version}.tar" # TODO: use sm-ll for this.
fi
@@ -124,7 +124,7 @@ extension_package()
extension_publish()
{
local _name="${1:-}" _path _version _file
- shift || fail "Cannot publish an extension; no extension name was given."
+ shift || __sm.log.fail "Cannot publish an extension; no extension name was given."
NIY "Extension publishing locally and to extensions.beginrescueend.com has not yet been implemented."
@@ -133,22 +133,22 @@ extension_publish()
paths enter "${_path}"
__sm.extension.is.valid "${_path}/${_name}" ||
- error "Cannot package extension '${_name}'; the extension is not valid."
+ __sm.log.error "Cannot package extension '${_name}'; the extension is not valid."
_version="$(cat "${_name}/VERSION")"
log "Packaging extension ${_name}"
log "${_name}-${_version}:"
paths exists "${_path}/pkg/" ||
- error "The local package path '${_path}' does not exist; did you run"\
+ __sm.log.error "The local package path '${_path}' does not exist; did you run"\
"'extension package ${_name}' before 'extension publish ${_name}'?"
log "publishing ${_name}-${_version}"
for _file in "${_pth}/${_name}-${_version}".{tar.gz,tar.xz,tar.bz2,zip}
do
- log_step " - ${_file}"
- log_step " - ${_file}.md5"
+ __sm.log.step " - ${_file}"
+ __sm.log.step " - ${_file}.md5"
done
log "Packaging complete. (Packages are located in '${_path}/pkg' )"
View
22 core/cli/shell/ext/functions
@@ -65,7 +65,7 @@ ext_list_known()
ext_install()
{
local _name _names="$1" _uri="$2"
- shift || fail "No extension name was given."
+ shift || __sm.log.fail "No extension name was given."
_names=(${_names//,/ })
@@ -75,7 +75,7 @@ ext_install()
for _name in ${_names[@]}
do
- log_step "Installing ${_name} in ${_extension_namespace//\// }" \
+ __sm.log.step "Installing ${_name} in ${_extension_namespace//\// }" \
extension install as "${_name}" ${_uri:+from} ${_uri}
done
}
@@ -96,31 +96,31 @@ ext_update()
{
local _name _uri
(( $# > 0 )) ||
- error "Cannot update extension ext without name."
+ __sm.log.error "Cannot update extension ext without name."
for _name in "$@"
do
if [[ ! -d "${exts_user_path}/active/${_name}" ]]
then
if [[ -d "${exts_system_path}/active/${_name}" ]]
then
- error "Extension ${_name} is in system exts and cannot be updated."
+ __sm.log.error "Extension ${_name} is in system exts and cannot be updated."
else
- error "Extension ${_name} does not exist."
+ __sm.log.error "Extension ${_name} does not exist."
fi
fi
if [[ ! -s "${exts_user_path}/active/${_name}/.uri" ]]
then
- warn "Extension ${_name} does not contain stored uri."
+ __sm.log.warn "Extension ${_name} does not contain stored uri."
continue
fi
_uri=$( __sm.vcs.read_uri "${exts_user_path}/active/${_name}/.uri" )
if [[ -z "${_uri}" ]]
then
- warn "Extension ${_name} does not contain stored uri."
+ __sm.log.warn "Extension ${_name} does not contain stored uri."
else
ext_install "${_name}" "${_uri}"
fi
@@ -133,7 +133,7 @@ ext_update_all()
if (( ! "${#_entries[@]}" ))
then
- error "No extensions found for update."
+ __sm.log.error "No extensions found for update."
fi
for _name in "${_entries[@]}"
@@ -148,17 +148,17 @@ ext_uninstall()
local _name="$1"
case "${_name}" in
*/*|.|..)
- error "Please specify a valid extension name."
+ __sm.log.error "Please specify a valid extension name."
;;
esac
if [[ ! -d "${exts_user_path}/active/${_name}" ]]
then
if [[ -d "${exts_system_path}/active/${_name}" ]]
then
- error "Extension ${_name} is in system exts and cannot be uninstalled."
+ __sm.log.error "Extension ${_name} is in system exts and cannot be uninstalled."
else
- error "Extension ${_name} does not exist."
+ __sm.log.error "Extension ${_name} does not exist."
fi
fi
View
6 core/cli/shell/functions
@@ -45,7 +45,7 @@ extension_cli()
actions()
{
local _action="$1"
- shift || fail "Actions command not given."
+ shift || __sm.log.fail "Actions command not given."
while (( $# ))
do
@@ -60,11 +60,11 @@ actions()
(search)
;;
(*)
- fail "Unknown command maps '${_token}'"
+ __sm.log.fail "Unknown command maps '${_token}'"
;;
esac
(*)
- fail "Unknown command '${_token}'"
+ __sm.log.fail "Unknown command '${_token}'"
;;
esac
done
View
4 core/cli/shell/get/functions
@@ -3,7 +3,7 @@
fetch_version()
{
version=$(curl -s "${releases_url}/latest-version.txt" 2>/dev/null) ||
- fail "Unable to fetch version from ${releases_url}/latest-version.txt"
+ __sm.log.fail "Unable to fetch version from ${releases_url}/latest-version.txt"
}
md5_match()
@@ -60,7 +60,7 @@ install_release()