Skip to content

Commit 0d65e53

Browse files
mikkoioalders
authored andcommitted
Add Bash completion
1 parent 4e92da8 commit 0d65e53

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

share/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Other Content
2+
3+
## Command Completion
4+
5+
### Installation
6+
7+
For Bash:
8+
9+
Copy the completion script to operating sytem specific folder, e.g.
10+
11+
* /usr/share/bash-completion/completions/
12+
* /etc/bash_completion.d
13+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
3+
__mech_dump_init_completion() {
4+
COMPREPLY=()
5+
_get_comp_words_by_ref cur prev words cword
6+
}
7+
__mech_dump_command_line_options() {
8+
opts=(
9+
--headers --forms --links --images --all --test
10+
--user= --password= --cookie-file= --agent
11+
--agent-alias= --absolute --help --version
12+
*
13+
)
14+
echo "${opts[*]}"
15+
}
16+
17+
_mech_dump() {
18+
local cur
19+
if declare -F _init_completion >/dev/null 2>&1; then
20+
_init_completion
21+
else
22+
__mech_dump_init_completion
23+
fi
24+
25+
keys=( )
26+
cur=${COMP_WORDS[COMP_CWORD]}
27+
28+
keys+=( "$(__mech_dump_command_line_options)" )
29+
# shellcheck disable=SC2207
30+
COMPREPLY=( $( compgen -W "${keys[*]}" -- "$cur" ) )
31+
return 0
32+
}
33+
34+
complete -F _mech_dump mech-dump

0 commit comments

Comments
 (0)