Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completions: clear and consistent log messages #2063

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
30 changes: 30 additions & 0 deletions clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,50 +33,80 @@ lint_clean_files.sh
#
completion/available/apm.completion.bash
completion/available/awless.completion.bash
completion/available/awscli.completion.bash
completion/available/bash-it.completion.bash
completion/available/brew.completion.bash
#completion/available/capistrano.completion.bash
completion/available/cargo.completion.bash
completion/available/composer.completion.bash
completion/available/conda.completion.bash
completion/available/consul.completion.bash
completion/available/crystal.completion.bash
completion/available/dart.completion.bash
completion/available/defaults.completion.bash
completion/available/dirs.completion.bash
completion/available/django.completion.bash
completion/available/dmidecode.completion.bash
completion/available/docker-machine.completion.bash
completion/available/docker.completion.bash
completion/available/dotnet.completion.bash
completion/available/drush.completion.bash
completion/available/export.completion.bash
completion/available/flutter.completion.bash
completion/available/gcloud.completion.bash
completion/available/gem.completion.bash
completion/available/git.completion.bash
completion/available/github-cli.completion.bash
completion/available/go.completion.bash
completion/available/helm.completion.bash
completion/available/homesick.completion.bash
completion/available/jboss5.completion.bash
completion/available/jboss7.completion.bash
completion/available/jungle.completion.bash
completion/available/kind.completion.bash
completion/available/knife.completion.bash
completion/available/kontena.completion.bash
completion/available/kubectl.completion.bash
completion/available/laravel.completion.bash
completion/available/lerna.completion.bash
completion/available/makefile.completion.bash
#completion/available/maven.completion.bash
completion/available/minikube.completion.bash
completion/available/minishift.completion.bash
completion/available/ng.completion.bash
completion/available/ngrok.completion.bash
completion/available/notify-send.completion.bash
completion/available/npm.completion.bash
completion/available/nvm.completion.bash
completion/available/openshift.completion.bash
completion/available/packer.completion.bash
completion/available/pew.completion.bash
completion/available/pip.completion.bash
completion/available/pip3.completion.bash
completion/available/pipenv.completion.bash
completion/available/pipx.completion.bash
#completion/available/projects.completion.bash
#completion/available/rake.completion.bash
completion/available/rustup.completion.bash
completion/available/rvm.completion.bash
completion/available/sdkman.completion.bash
#completion/available/sqlmap.completion.bash
#completion/available/ssh.completion.bash
completion/available/svn.completion.bash
completion/available/system.completion.bash
completion/available/terraform.completion.bash
#completion/available/test_kitchen.completion.bash
completion/available/todo.completion.bash
completion/available/travis.completion.bash
completion/available/vault.completion.bash
completion/available/virsh.completion.bash
#completion/available/virtualbox.completion.bash
completion/available/vuejs.completion.bash
completion/available/wpscan.completion.bash

# libraries
lib/colors.bash
lib/completion.bash
lib/helpers.bash
lib/history.bash
lib/log.bash
Expand Down
4 changes: 2 additions & 2 deletions completion/available/apm.completion.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# shellcheck shell=bash
about-completion "apm completion"
# shellcheck disable=SC1090
source "${BASH_IT}"/vendor/github.com/vigo/apm-bash-completion/apm
# shellcheck source-path=SCRIPTDIR/../../vendor/github.com/vigo/apm-bash-completion
source "${BASH_IT?}/vendor/github.com/vigo/apm-bash-completion/apm"
13 changes: 9 additions & 4 deletions completion/available/awless.completion.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# shellcheck shell=bash
if _command_exists awless; then
# shellcheck disable=SC1090
source <(awless completion bash)
fi

# Make sure awless is installed
_bash-it-completion-helper-necessary awless || return

# Don't handle completion if it's already managed
_bash-it-completion-helper-sufficient awless || return

# shellcheck disable=SC1090
source <(awless completion bash)
11 changes: 7 additions & 4 deletions completion/available/awscli.completion.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# shellcheck shell=bash

if _command_exists aws_completer
then
complete -C "$(command -v aws_completer)" aws
fi
# Make sure aws is installed
_bash-it-completion-helper-necessary aws aws_completer || return

# Don't handle completion if it's already managed
_bash-it-completion-helper-sufficient aws || return

complete -C aws_completer aws
12 changes: 8 additions & 4 deletions completion/available/cargo.completion.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# shellcheck shell=bash
# cargo (Rust package manager) completion
about-completion "cargo (Rust package manager) completion"

if _binary_exists rustup && _binary_exists cargo; then
eval "$(rustup completions bash cargo)"
fi
# Make sure cargo is installed
_bash-it-completion-helper-necessary rustup cargo || return

# Don't handle completion if it's already managed
_bash-it-completion-helper-sufficient cargo || return

eval "$(rustup completions bash cargo)"
1 change: 0 additions & 1 deletion completion/available/conda.completion.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# shellcheck shell=bash
cite "about-completion"
about-completion "conda completion"

if _command_exists conda; then
Expand Down
11 changes: 7 additions & 4 deletions completion/available/consul.completion.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# shellcheck shell=bash
cite "about-completion"
about-completion "Hashicorp consul completion"

if _command_exists consul; then
complete -C "$(command -v consul)" consul
fi
# Make sure consul is installed
_bash-it-completion-helper-necessary consul || return

# Don't handle completion if it's already managed
_bash-it-completion-helper-sufficient consul || return

complete -C consul consul
5 changes: 4 additions & 1 deletion completion/available/crystal.completion.bash
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
_log_warning 'Bash completion for "crystal" is now covered by "system". This completion can be disabled.'
# shellcheck shell=bash

_log_warning 'Bash completion for "crystal" is now covered by "system".'
_disable-completion "crystal"
5 changes: 3 additions & 2 deletions completion/available/defaults.completion.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# shellcheck shell=bash

if test -s "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash"; then
source "$_"
if [[ -s "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash" ]]; then
# shellcheck source-path=SCRIPTDIR/../../vendor/github.com/gaelicWizard/bash-progcomp
source "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash"
fi
20 changes: 9 additions & 11 deletions completion/available/dirs.completion.bash
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/usr/bin/env bash
# Bash completion support for the 'dirs' plugin (commands G, R).
# shellcheck shell=bash
about-completion "Bash completion support for the 'dirs' plugin (commands G, R)."

_dirs-complete() {
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"
function _dirs-complete() {
# parse all defined shortcuts ${BASH_IT_DIRS_BKS}
if [[ -s "${BASH_IT_DIRS_BKS:-/dev/null}" ]]; then
IFS=$'\n' read -d '' -ra COMPREPLY < <(grep -v '^#' "${BASH_IT_DIRS_BKS?}" | sed -e 's/\(.*\)=.*/\1/')
fi

# parse all defined shortcuts from ~/.dirs
if [ -r "$HOME/.dirs" ]; then
COMPREPLY=($(compgen -W "$(grep -v '^#' ~/.dirs | sed -e 's/\(.*\)=.*/\1/')" -- ${CURRENT_PROMPT}) )
fi

return 0
return 0
}

complete -o default -o nospace -F _dirs-complete G R
complete -o default -o nospace -F _dirs-complete -X '!&*' G R
19 changes: 11 additions & 8 deletions completion/available/dmidecode.completion.bash
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# shellcheck shell=bash

function __dmidecode_completion() {
# shellcheck disable=SC2155
local prev=$(_get_pword)
# shellcheck disable=SC2155
local curr=$(_get_cword)
# Make sure dmidecode is installed
_bash-it-completion-helper-necessary dmidecode || :

# Don't handle completion if it's already managed
_bash-it-completion-helper-sufficient dmidecode || return

function _dmidecode() {
local prev="${COMP_WORDS[COMP_CWORD - 1]}"

case $prev in
-s | --string | -t | --type)
OPTS=$(dmidecode "$prev" 2>&1 | grep -E '^ ' | sed 's/ *//g')
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$OPTS" -- "$curr"))
COMPREPLY=("${OPTS[@]}")
;;
dmidecode)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-d --dev-mem -h --help -q --quiet -s --string -t --type -H --handle -u --dump{,-bin} --from-dump --no-sysfs --oem-string -V --version" -- "$curr"))
COMPREPLY=("-d" "--dev-mem" "-h" "--help" "-q" "--quiet" "-s" "--string" "-t" "--type" "-H" "--handle" "-u" "--dump" "-dump-bin" "--from-dump" "--no-sysfs" "--oem-string" "-V" "--version")
;;
esac
}

complete -F __dmidecode_completion dmidecode
complete -F _dmidecode -X '!&*' dmidecode
24 changes: 16 additions & 8 deletions completion/available/docker.completion.bash
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
# shellcheck shell=bash
cite "about-completion"
about-completion "docker completion"

# Make sure docker is installed
_command_exists docker || return
_bash-it-completion-helper-necessary docker || :

# Don't handle completion if it's already managed
_completion_exists docker && return
_bash-it-completion-helper-sufficient docker || return

_docker_bash_completion_paths=(
# MacOS
# MacOS App
'/Applications/Docker.app/Contents/Resources/etc/docker.bash-completion'
# Linux
# Command Line
'/usr/share/bash-completion/completions/docker'
)

for fn in "${_docker_bash_completion_paths[@]}"; do
if [ -r "$fn" ]; then
# Load the first completion file found
_docker_bash_completion_found=false
for _comp_path in "${_docker_bash_completion_paths[@]}"; do
if [[ -r "$_comp_path" ]]; then
_docker_bash_completion_found=true
# shellcheck disable=SC1090
source "$fn"
source "$_comp_path"
break
fi
done

# Cleanup
if [[ "${_docker_bash_completion_found}" == false ]]; then
_log_warning "no completion files found - please try enabling the 'system' completion instead."
fi
unset "${!_docker_bash_completion@}"
3 changes: 3 additions & 0 deletions completion/available/drush.completion.bash
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# shellcheck shell=bash

_log_warning 'Bash completion for "drush" is now deprecated, as it used code with incompatible license.
Please disable this completion and use the instructions from "drush" developers instead.'
_disable-completion "drush"
5 changes: 4 additions & 1 deletion completion/available/export.completion.bash
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
complete -o nospace -S = -W '$(printenv | awk -F= "{print \$1}")' export
# shellcheck shell=bash

_log_warning 'Bash completion for "export" is now covered by "system".'
_disable-completion "export"
12 changes: 8 additions & 4 deletions completion/available/flutter.completion.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/bash
# shellcheck shell=bash

if _command_exists flutter; then
eval "$(flutter bash-completion)"
fi
# Make sure flutter is installed
_bash-it-completion-helper-necessary flutter || return

# Don't handle completion if it's already managed
_bash-it-completion-helper-sufficient flutter || return

eval "$(flutter bash-completion)"
1 change: 0 additions & 1 deletion completion/available/gcloud.completion.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# shellcheck shell=bash
cite "about-completion"
about-completion "Google Cloud SDK completion"

if _command_exists gcloud; then
Expand Down
7 changes: 2 additions & 5 deletions completion/available/git.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
# Locate and load completions for `git`.

# Make sure git is installed
_command_exists git || return
_bash-it-completion-helper-necessary git || :

# Don't handle completion if it's already managed
if complete -p git &> /dev/null; then
_log_warning "completion already loaded - this usually means it is safe to stop using this completion"
return 0
fi
_bash-it-completion-helper-sufficient git || return

_git_bash_completion_xcrun_git=
if _command_exists xcrun; then
Expand Down
13 changes: 7 additions & 6 deletions completion/available/github-cli.completion.bash
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# shellcheck shell=bash
cite "about-completion"
about-completion "GitHub CLI completion"

if _binary_exists gh; then
# If gh already completed, stop
_completion_exists gh && return
eval "$(gh completion --shell=bash)"
fi
# Make sure gh is installed
_bash-it-completion-helper-necessary gh || return

# Don't handle completion if it's already managed
_bash-it-completion-helper-sufficient gh || return

eval "$(gh completion --shell=bash)"
11 changes: 7 additions & 4 deletions completion/available/helm.completion.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# shellcheck shell=bash
cite "about-completion"
about-completion "helm (Kubernetes Package Manager) completion"

if _command_exists helm; then
eval "$(helm completion bash)"
fi
# Make sure helm is installed
_bash-it-completion-helper-necessary helm || return

# Don't handle completion if it's already managed
_bash-it-completion-helper-sufficient helm || return

eval "$(helm completion bash)"
3 changes: 3 additions & 0 deletions completion/available/homesick.completion.bash
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# shellcheck shell=bash

_log_warning 'Bash completion for "homesick" is now deprecated, as it used unlicensed code.
Please disable this completion and use the instructions from "homesick" bash completion developers instead.'
_disable-completion "homesick"
11 changes: 7 additions & 4 deletions completion/available/jungle.completion.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# shellcheck shell=bash
cite "about-completion"
about-completion "jungle(AWS cli tool) completion"

if _command_exists jungle; then
eval "$(_JUNGLE_COMPLETE=source jungle)"
fi
# Make sure jungle is installed
_bash-it-completion-helper-necessary jungle || return

# Don't handle completion if it's already managed
_bash-it-completion-helper-sufficient jungle || return

eval "$(_JUNGLE_COMPLETE=source jungle)"
12 changes: 8 additions & 4 deletions completion/available/kind.completion.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash
# shellcheck shell=bash

if _command_exists kind; then
eval "$(kind completion bash)"
fi
# Make sure kind is installed
_bash-it-completion-helper-necessary kind || return

# Don't handle completion if it's already managed
_bash-it-completion-helper-sufficient kind || return

eval "$(kind completion bash)"
13 changes: 9 additions & 4 deletions completion/available/kontena.completion.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# shellcheck shell=bash
if _command_exists kontena; then
# shellcheck disable=SC1090
source "$(kontena whoami --bash-completion-path)"
fi

# Make sure kontena is installed
_bash-it-completion-helper-necessary kontena || return

# Don't handle completion if it's already managed
_bash-it-completion-helper-sufficient kontena || return

# shellcheck disable=SC1090
source "$(kontena whoami --bash-completion-path)"
Loading