Shell completions
This commit is contained in:
parent
11777c5f24
commit
2bdedefa05
12
Makefile
12
Makefile
@ -161,6 +161,18 @@ BINS+=health
|
||||
|
||||
buildall: $(BINS)
|
||||
|
||||
completions:
|
||||
./scripts/make-completions.sh lotus
|
||||
./scripts/make-completions.sh lotus-storage-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-storage-miner /usr/share/bash-completion/completions/lotus-storage-miner
|
||||
install -C ./scripts/zsh-completion/lotus /usr/local/share/zsh/site-functions/_lotus
|
||||
install -C ./scripts/zsh-completion/lotus-storage-miner /usr/local/share/zsh/site-functions/_lotus-storage-miner
|
||||
|
||||
clean:
|
||||
rm -rf $(CLEAN) $(BINS)
|
||||
-$(MAKE) -C $(FFI_PATH) clean
|
||||
|
@ -57,6 +57,7 @@ func main() {
|
||||
Name: "lotus-storage-miner",
|
||||
Usage: "Filecoin decentralized storage network storage miner",
|
||||
Version: build.UserVersion,
|
||||
EnableShellCompletion: true,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "repo",
|
||||
|
@ -50,9 +50,10 @@ func main() {
|
||||
defer span.End()
|
||||
|
||||
app := &cli.App{
|
||||
Name: "lotus",
|
||||
Usage: "Filecoin decentralized storage network client",
|
||||
Version: build.UserVersion,
|
||||
Name: "lotus",
|
||||
Usage: "Filecoin decentralized storage network client",
|
||||
Version: build.UserVersion,
|
||||
EnableShellCompletion: true,
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "repo",
|
||||
|
@ -1,3 +0,0 @@
|
||||
From https://github.com/filecoin-project/go-filecoin/tree/master/scripts
|
||||
|
||||
Try to keep in sync
|
10
scripts/bash-completion/lotus
Normal file
10
scripts/bash-completion/lotus
Normal file
@ -0,0 +1,10 @@
|
||||
#!/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
|
10
scripts/bash-completion/lotus-storage-miner
Normal file
10
scripts/bash-completion/lotus-storage-miner
Normal file
@ -0,0 +1,10 @@
|
||||
#!/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-storage-miner
|
9
scripts/make-completions.sh
Executable file
9
scripts/make-completions.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/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"
|
12
scripts/zsh-completion/lotus
Normal file
12
scripts/zsh-completion/lotus
Normal file
@ -0,0 +1,12 @@
|
||||
#!/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
|
12
scripts/zsh-completion/lotus-storage-miner
Normal file
12
scripts/zsh-completion/lotus-storage-miner
Normal file
@ -0,0 +1,12 @@
|
||||
#!/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-storage-miner
|
Loading…
Reference in New Issue
Block a user