Fix shell completions
This commit is contained in:
parent
2d4eaf08c4
commit
559c76a214
7
Makefile
7
Makefile
@ -303,17 +303,10 @@ clean-services: clean-all-services
|
||||
|
||||
buildall: $(BINS)
|
||||
|
||||
completions:
|
||||
./scripts/make-completions.sh lotus
|
||||
./scripts/make-completions.sh lotus-miner
|
||||
.PHONY: completions
|
||||
|
||||
install-completions:
|
||||
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-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-miner /usr/local/share/zsh/site-functions/_lotus-miner
|
||||
|
||||
clean:
|
||||
rm -rf $(CLEAN) $(BINS)
|
||||
|
@ -63,9 +63,10 @@ func main() {
|
||||
}
|
||||
|
||||
app := &cli.App{
|
||||
Name: "lotus-worker",
|
||||
Usage: "Remote miner worker",
|
||||
Version: build.UserVersion(),
|
||||
Name: "lotus-worker",
|
||||
Usage: "Remote miner worker",
|
||||
Version: build.UserVersion(),
|
||||
EnableBashCompletion: true,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: FlagWorkerRepo,
|
||||
|
@ -1,10 +1,18 @@
|
||||
#!/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
|
||||
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
|
||||
local cur opts base
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
if [[ "$cur" == "-"* ]]; then
|
||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion )
|
||||
else
|
||||
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
|
||||
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
|
||||
#compdef lotus lotus-miner lotus-worker
|
||||
|
||||
_cli_zsh_autocomplete() {
|
||||
|
||||
local -a opts
|
||||
local cur
|
||||
cur=${words[-1]}
|
||||
if [[ "$cur" == "-"* ]]; then
|
||||
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
|
||||
else
|
||||
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
|
||||
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