Skip to content

Commit cf73294

Browse files
committed
Merge pull request #96 from georgelesica-wf/bash_completions
CP-1122 Bash completions
2 parents e0c477d + a3671fe commit cf73294

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,26 @@ Add the following to your bash or zsh profile for convenience:
9595
alias ddev='pub run dart_dev'
9696
```
9797

98+
#### Bash Completion
99+
100+
Symlink or copy the file `tool/ddev-completion.sh` into
101+
`/etc/bash_completion.d/` (or wherever your completion scripts live, if you
102+
have installed Bash through Homebrew on a Mac, for instance, this will be
103+
`/usr/local/etc/bash_completion.d/`).
104+
105+
If you are using Bash installed through Homebrew, you'll also need to install
106+
the completion machinery with `brew install bash-completion`. Then make sure
107+
something like the following is in your `.bashrc` file:
108+
109+
```
110+
if [ -f $(brew --prefix)/etc/bash_completion ]; then
111+
. $(brew --prefix)/etc/bash_completion
112+
fi
113+
```
114+
115+
Next time you load a Bash session you'll have basic completions for the `ddev`
116+
alias described above.
117+
98118
#### Configuration
99119
In order to configure `dart_dev` for a specific project, run `ddev init` or
100120
`pub run dart_dev init` to generate the configuration file. This should create a

tool/ddev-completion.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
_ddev()
2+
{
3+
local cur prev cmds
4+
5+
COMPREPLY=()
6+
7+
cur="${COMP_WORDS[COMP_CWORD]}"
8+
prev="${COMP_WORDS[COMP_CWORD-1]}"
9+
cmds="--help --quiet --version --color --no-color analyze copy-license coverage docs examples format init test"
10+
11+
#
12+
# Complete subcommand options instead of top-level commands and options.
13+
#
14+
15+
if [[ " ${COMP_WORDS[*]} " == *" analyze "* ]]; then
16+
cmds="--help --fatal-warnings --no-fatal-warnings --hints --no-hints"
17+
fi
18+
19+
if [[ " ${COMP_WORDS[*]} " == *" coverage "* ]]; then
20+
cmds="--help --unit --no-unit --integration --no-integration --html --no-html --open --no-open"
21+
fi
22+
23+
if [[ " ${COMP_WORDS[*]} " == *" docs "* ]]; then
24+
cmds="--help --open --no-open"
25+
fi
26+
27+
if [[ " ${COMP_WORDS[*]} " == *" examples "* ]]; then
28+
cmds="--help --hostname --port"
29+
fi
30+
31+
if [[ " ${COMP_WORDS[*]} " == *" format "* ]]; then
32+
cmds="--help --check --line-length"
33+
fi
34+
35+
if [[ " ${COMP_WORDS[*]} " == *" test "* ]]; then
36+
cmds="--help --unit --no-unit --integration --no-integration --concurrency --platform"
37+
fi
38+
39+
COMPREPLY=($(compgen -W "${cmds}" -- ${cur}))
40+
return 0
41+
}
42+
complete -F _ddev ddev
43+

0 commit comments

Comments
 (0)