diff --git a/one-cmds/help b/one-cmds/help index df2aa9c..6e15a5c 100755 --- a/one-cmds/help +++ b/one-cmds/help @@ -53,15 +53,15 @@ print_help() { local file="$ONE_DIR/one-cmds/$cmd" local label arg - if [[ ! -x "$file" ]]; then - printf '%s: Not found sub-command "%s". No executable file: %s\n' 'one.bash' "$cmd" "$file" >&2 + if [[ ! -x "${file}" ]]; then + printf '%bNot found command "%s".%b\n' "$YELLOW" "$cmd" "$RESET_ALL" >&2 return "$ONE_EX_USAGE" fi label=$( grep -i '^# one.bash:usage' "$file" 2>/dev/null || true ) if [[ -z "$label" ]]; then - echo "The command '$cmd' has not usage document." >&2 + printf '%bThe command "%s" has not usage document.%b\n' "$YELLOW" "$cmd" "$RESET_ALL" >&2 return "$ONE_EX_UNAVAILABLE" fi diff --git a/one-cmds/help-sub b/one-cmds/help-sub index 2c92ed0..40b8c4d 100755 --- a/one-cmds/help-sub +++ b/one-cmds/help-sub @@ -45,6 +45,9 @@ fi # shellcheck source=../deps/colors.bash . "$ONE_DIR/deps/colors.bash" +# shellcheck source=../bash/exit-codes.bash +. "$ONE_DIR/bash/exit-codes.bash" + colorful() { local line while IFS=$'\n' read -r line; do @@ -68,21 +71,21 @@ print_help() { fi done - if [[ ! -f ${file:-} ]]; then - printf '%s: Not found ONE_SUB command "%s".\n' 'one.bash' "$cmd" >&2 - return 2 + if [[ -z ${file:-} ]]; then + printf '%bNot found ONE_SUB command "%s".%b\n' "$YELLOW" "$cmd" "$RESET_ALL" >&2 + return "$ONE_EX_USAGE" fi if [[ ! -x "${file}" ]]; then - printf '%s: Not found ONE_SUB command "%s". No executable file: %s\n' 'one.bash' "$cmd" "$file" >&2 - return 1 + printf '%bNot found ONE_SUB command "%s". File is not executable or not existed: %s%b\n' "$YELLOW" "$cmd" "$file" "$RESET_ALL" >&2 + return "$ONE_EX_USAGE" fi label=$( grep -i '^# one.bash:usage' "$file" 2>/dev/null || true ) if [[ -z "$label" ]]; then - echo "The command '$cmd' has not usage document." >&2 - return 0 + printf '%bThe command "%s" has not usage document.%b\n' "$YELLOW" "$cmd" "$RESET_ALL" >&2 + return "$ONE_EX_UNAVAILABLE" fi arg=$( sed -E 's/^# one.bash:usage(:?.*)/\1/i' <<<"$label" || true )