Merge pull request #6316 from Aloxaf/fix_completion
Fix shell completions
This commit is contained in:
commit
05082e262a
7
Makefile
7
Makefile
@ -303,17 +303,10 @@ clean-services: clean-all-services
|
|||||||
|
|
||||||
buildall: $(BINS)
|
buildall: $(BINS)
|
||||||
|
|
||||||
completions:
|
|
||||||
./scripts/make-completions.sh lotus
|
|
||||||
./scripts/make-completions.sh lotus-miner
|
|
||||||
.PHONY: completions
|
|
||||||
|
|
||||||
install-completions:
|
install-completions:
|
||||||
mkdir -p /usr/share/bash-completion/completions /usr/local/share/zsh/site-functions/
|
mkdir -p /usr/share/bash-completion/completions /usr/local/share/zsh/site-functions/
|
||||||
install -C ./scripts/bash-completion/lotus /usr/share/bash-completion/completions/lotus
|
install -C ./scripts/bash-completion/lotus /usr/share/bash-completion/completions/lotus
|
||||||
install -C ./scripts/bash-completion/lotus-miner /usr/share/bash-completion/completions/lotus-miner
|
|
||||||
install -C ./scripts/zsh-completion/lotus /usr/local/share/zsh/site-functions/_lotus
|
install -C ./scripts/zsh-completion/lotus /usr/local/share/zsh/site-functions/_lotus
|
||||||
install -C ./scripts/zsh-completion/lotus-miner /usr/local/share/zsh/site-functions/_lotus-miner
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(CLEAN) $(BINS)
|
rm -rf $(CLEAN) $(BINS)
|
||||||
|
@ -66,6 +66,7 @@ func main() {
|
|||||||
Name: "lotus-worker",
|
Name: "lotus-worker",
|
||||||
Usage: "Remote miner worker",
|
Usage: "Remote miner worker",
|
||||||
Version: build.UserVersion(),
|
Version: build.UserVersion(),
|
||||||
|
EnableBashCompletion: true,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: FlagWorkerRepo,
|
Name: FlagWorkerRepo,
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
_cli_bash_autocomplete() {
|
_cli_bash_autocomplete() {
|
||||||
local cur opts base;
|
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
|
||||||
COMPREPLY=();
|
local cur opts base
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}";
|
COMPREPLY=()
|
||||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-completion );
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) );
|
if [[ "$cur" == "-"* ]]; then
|
||||||
return 0;
|
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion )
|
||||||
};
|
else
|
||||||
complete -F _cli_bash_autocomplete lotus
|
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
|
||||||
|
fi
|
||||||
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete lotus lotus-miner lotus-worker
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
_cli_bash_autocomplete() {
|
|
||||||
local cur opts base;
|
|
||||||
COMPREPLY=();
|
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}";
|
|
||||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-completion );
|
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) );
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
complete -F _cli_bash_autocomplete lotus-miner
|
|
@ -1,9 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# scripts/make-completions.sh [progname]
|
|
||||||
|
|
||||||
echo '#!/usr/bin/env bash' > "scripts/bash-completion/$1"
|
|
||||||
echo '#!/usr/bin/env zsh' > "scripts/zsh-completion/$1"
|
|
||||||
|
|
||||||
$1 --init-completion=bash >> "scripts/bash-completion/$1"
|
|
||||||
$1 --init-completion=zsh >> "scripts/zsh-completion/$1"
|
|
@ -1,12 +1,23 @@
|
|||||||
#!/usr/bin/env zsh
|
#compdef lotus lotus-miner lotus-worker
|
||||||
autoload -U compinit && compinit;
|
|
||||||
autoload -U bashcompinit && bashcompinit;
|
_cli_zsh_autocomplete() {
|
||||||
_cli_bash_autocomplete() {
|
|
||||||
local cur opts base;
|
local -a opts
|
||||||
COMPREPLY=();
|
local cur
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}";
|
cur=${words[-1]}
|
||||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-completion );
|
if [[ "$cur" == "-"* ]]; then
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) );
|
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
|
||||||
return 0;
|
else
|
||||||
};
|
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
|
||||||
complete -F _cli_bash_autocomplete lotus
|
fi
|
||||||
|
|
||||||
|
if [[ "${opts[1]}" != "" ]]; then
|
||||||
|
_describe 'values' opts
|
||||||
|
else
|
||||||
|
_files
|
||||||
|
fi
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef _cli_zsh_autocomplete lotus lotus-miner lotus-worker
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
autoload -U compinit && compinit;
|
|
||||||
autoload -U bashcompinit && bashcompinit;
|
|
||||||
_cli_bash_autocomplete() {
|
|
||||||
local cur opts base;
|
|
||||||
COMPREPLY=();
|
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}";
|
|
||||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-completion );
|
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) );
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
complete -F _cli_bash_autocomplete lotus-miner
|
|
Loading…
Reference in New Issue
Block a user