Skip to content

Commit 6e60a40

Browse files
committed
completions: clear and consistent log messages
TODO: `pew` TODO: `source <(flutter bash-completion)` vs `eval $(flutter bash-completion)`...saves a subshell...
1 parent 8fb8091 commit 6e60a40

28 files changed

+223
-128
lines changed
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# shellcheck shell=bash
2-
if _command_exists awless; then
3-
# shellcheck disable=SC1090
4-
source <(awless completion bash)
5-
fi
2+
3+
# Make sure awless is installed
4+
_bash-it-completion-helper-necessary awless || return
5+
6+
# Don't handle completion if it's already managed
7+
_bash-it-completion-helper-sufficient awless || return
8+
9+
# shellcheck disable=SC1090
10+
source <(awless completion bash)
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# shellcheck shell=bash
22

3-
if _command_exists aws_completer
4-
then
5-
complete -C "$(command -v aws_completer)" aws
6-
fi
3+
# Make sure aws is installed
4+
_bash-it-completion-helper-necessary aws aws_completer || return
5+
6+
# Don't handle completion if it's already managed
7+
_bash-it-completion-helper-sufficient aws || return
8+
9+
complete -C aws_completer aws
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# shellcheck shell=bash
2-
# cargo (Rust package manager) completion
2+
about-completion "cargo (Rust package manager) completion"
33

4-
if _binary_exists rustup && _binary_exists cargo; then
5-
eval "$(rustup completions bash cargo)"
6-
fi
4+
# Make sure cargo is installed
5+
_bash-it-completion-helper-necessary rustup cargo || return
6+
7+
# Don't handle completion if it's already managed
8+
_bash-it-completion-helper-sufficient cargo || return
9+
10+
eval "$(rustup completions bash cargo)"
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# shellcheck shell=bash
2-
cite "about-completion"
32
about-completion "Hashicorp consul completion"
43

5-
if _command_exists consul; then
6-
complete -C "$(command -v consul)" consul
7-
fi
4+
# Make sure consul is installed
5+
_bash-it-completion-helper-necessary consul || return
6+
7+
# Don't handle completion if it's already managed
8+
_bash-it-completion-helper-sufficient consul || return
9+
10+
complete -C consul consul
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
#!/usr/bin/bash
1+
# shellcheck shell=bash
22

3-
if _command_exists flutter; then
4-
eval "$(flutter bash-completion)"
5-
fi
3+
# Make sure flutter is installed
4+
_bash-it-completion-helper-necessary flutter || return
5+
6+
# Don't handle completion if it's already managed
7+
_bash-it-completion-helper-sufficient flutter || return
8+
9+
eval "$(flutter bash-completion)"

completion/available/git.completion.bash

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
# Locate and load completions for `git`.
44

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

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

1411
_git_bash_completion_xcrun_git=
1512
if _command_exists xcrun; then
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# shellcheck shell=bash
2-
cite "about-completion"
32
about-completion "GitHub CLI completion"
43

5-
if _binary_exists gh; then
6-
# If gh already completed, stop
7-
_completion_exists gh && return
8-
eval "$(gh completion --shell=bash)"
9-
fi
4+
# Make sure gh is installed
5+
_bash-it-completion-helper-necessary gh || return
6+
7+
# Don't handle completion if it's already managed
8+
_bash-it-completion-helper-sufficient gh || return
9+
10+
eval "$(gh completion --shell=bash)"
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# shellcheck shell=bash
2-
cite "about-completion"
32
about-completion "helm (Kubernetes Package Manager) completion"
43

5-
if _command_exists helm; then
6-
eval "$(helm completion bash)"
7-
fi
4+
# Make sure helm is installed
5+
_bash-it-completion-helper-necessary helm || return
6+
7+
# Don't handle completion if it's already managed
8+
_bash-it-completion-helper-sufficient helm || return
9+
10+
eval "$(helm completion bash)"
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# shellcheck shell=bash
2-
cite "about-completion"
32
about-completion "jungle(AWS cli tool) completion"
43

5-
if _command_exists jungle; then
6-
eval "$(_JUNGLE_COMPLETE=source jungle)"
7-
fi
4+
# Make sure jungle is installed
5+
_bash-it-completion-helper-necessary jungle || return
6+
7+
# Don't handle completion if it's already managed
8+
_bash-it-completion-helper-sufficient jungle || return
9+
10+
eval "$(_JUNGLE_COMPLETE=source jungle)"
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
#!/usr/bin/env bash
1+
# shellcheck shell=bash
22

3-
if _command_exists kind; then
4-
eval "$(kind completion bash)"
5-
fi
3+
# Make sure kind is installed
4+
_bash-it-completion-helper-necessary kind || return
5+
6+
# Don't handle completion if it's already managed
7+
_bash-it-completion-helper-sufficient kind || return
8+
9+
eval "$(kind completion bash)"

0 commit comments

Comments
 (0)