* CI: disable Ubuntu 16.04 as it's EOL https://github.blog/changelog/2021-04-29-github-actions-ubuntu-16-04-lts-virtual-environment-will-be-removed-on-september-20-2021/ * main: lint false positive * install: lint * plugins/cmd-returned-notify: don't `export` * plugins/xterm: lint * plugins/git: lint * plugins/goenv: lint * plugins/alias-completion: lint false positives * plugins/alias-completion: fix SC2155, SC2154 Declare `locals` at the top of the function * completion: lint completions using `bash_completion` functions Match the style of the existing code * completion/knife: lint false positives * completion/knife: lint * completion/sdkman: lint * completion/composer: lint * Move `.shellcheckrc` under `themes/` * lib/theme: fix SC2155, SC2154, SC2034 * lib/colors: don't warn on unused variables We assign a large number of variables here and they may or may not be used anywhere else, so disable SC2034 for this file (only). Alsö disable SC2005 as the functions in this file were written before `printf` was invented and have to do some fancy metascripting to get escape sequences interpreted reliably. I’m not smart enough to fix this to use `printf`, so leave it for now. * themes/agnoster: lint * themes: disable SC2154 for colors Each one of these themes will need it’s own fix for SC2154, possibly upstream. Due to the way themes are, it's entirely normal to have a *lot* of false positives for SC2034. So much so, that I have to admit that it is probably just not worth linting for SC2034 despite my dislike of blanket ignore rules. * themes: disable SC2154, fix SC2155 Each one of these themes will need it’s own fix for SC2154, possibly upstream. Due to the way themes are, it's entirely normal to have a *lot* of false positives for SC2034. So much so, that I have to admit that it is probably just not worth linting for SC2034 despite my dislike of blanket ignore rules. * Delete `.shellcheckrc` * remove executable bit
61 lines
1.7 KiB
Bash
61 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
export BASH_IT_LOG_LEVEL_ERROR=1
|
|
export BASH_IT_LOG_LEVEL_WARNING=2
|
|
export BASH_IT_LOG_LEVEL_ALL=3
|
|
|
|
function _has_colors()
|
|
{
|
|
# Check that stdout is a terminal
|
|
test -t 1 || return 1
|
|
|
|
ncolors=$(tput colors)
|
|
test -n "$ncolors" && test "$ncolors" -ge 8 || return 1
|
|
return 0
|
|
}
|
|
|
|
function _log_general()
|
|
{
|
|
about 'Internal function used for logging, uses BASH_IT_LOG_PREFIX as a prefix'
|
|
param '1: color of the message'
|
|
param '2: log level to print before the prefix'
|
|
param '3: message to log'
|
|
group 'log'
|
|
|
|
message=$2${BASH_IT_LOG_PREFIX:-default: }$3
|
|
_has_colors && echo -e "$1${message}${echo_normal:-}" || echo -e "${message}"
|
|
}
|
|
|
|
function _log_debug()
|
|
{
|
|
about 'log a debug message by echoing to the screen. needs BASH_IT_LOG_LEVEL >= BASH_IT_LOG_LEVEL_ALL'
|
|
param '1: message to log'
|
|
example '$ _log_debug "Loading plugin git..."'
|
|
group 'log'
|
|
|
|
[[ "${BASH_IT_LOG_LEVEL:-0}" -ge $BASH_IT_LOG_LEVEL_ALL ]] || return 0
|
|
_log_general "${echo_green:-}" "DEBUG: " "$1"
|
|
}
|
|
|
|
function _log_warning()
|
|
{
|
|
about 'log a message by echoing to the screen. needs BASH_IT_LOG_LEVEL >= BASH_IT_LOG_LEVEL_WARNING'
|
|
param '1: message to log'
|
|
example '$ _log_warning "git binary not found, disabling git plugin..."'
|
|
group 'log'
|
|
|
|
[[ "${BASH_IT_LOG_LEVEL:-0}" -ge $BASH_IT_LOG_LEVEL_WARNING ]] || return 0
|
|
_log_general "${echo_yellow:-}" " WARN: " "$1"
|
|
}
|
|
|
|
function _log_error()
|
|
{
|
|
about 'log a message by echoing to the screen. needs BASH_IT_LOG_LEVEL >= BASH_IT_LOG_LEVEL_ERROR'
|
|
param '1: message to log'
|
|
example '$ _log_error "Failed to load git plugin..."'
|
|
group 'log'
|
|
|
|
[[ "${BASH_IT_LOG_LEVEL:-0}" -ge $BASH_IT_LOG_LEVEL_ERROR ]] || return 0
|
|
_log_general "${echo_red:-}" "ERROR: " "$1"
|
|
}
|