Skip to content

Commit 6a95541

Browse files
committed
Add tab completion for bash.
Signed-off-by: Eric Wang <[email protected]>
1 parent 57e96eb commit 6a95541

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Diff for: .lc-completion.bash

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
###-begin-lc-completions-###
2+
#
3+
# yargs command completion script
4+
#
5+
# Installation: bin/lc completion >> ~/.bashrc
6+
# or bin/lc completion >> ~/.bash_profile on OSX.
7+
#
8+
_yargs_completions()
9+
{
10+
local cur_word args type_list
11+
12+
cur_word="${COMP_WORDS[COMP_CWORD]}"
13+
args=("${COMP_WORDS[@]}")
14+
15+
# ask yargs to generate completions.
16+
type_list=$(lc --get-yargs-completions "${args[@]}")
17+
18+
COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )
19+
20+
# if no match was found, fall back to filename completion
21+
if [ ${#COMPREPLY[@]} -eq 0 ]; then
22+
COMPREPLY=( $(compgen -f -- "${cur_word}" ) )
23+
fi
24+
25+
return 0
26+
}
27+
complete -F _yargs_completions lc
28+
###-end-lc-completions-###

Diff for: lib/cli.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var yargs = require('yargs');
22

33
yargs.commandDir('commands')
4+
.completion()
45
.help()
56
.strict()
67
.argv;

0 commit comments

Comments
 (0)