mirror of
https://github.com/versity/versitygw.git
synced 2026-07-29 11:33:01 +00:00
feat: add cli option to generate shell auto completion
The urfave/cli/v2 has built-in auto-completion support for bash. This enables generating the auto completions with a cli option that can be added to environment setup scripts. Also adding some distro support scripts for rpm and deb for the auto completion setup. To enable auto completion in zsh, this still needs to be added to user .zshrc: fpath=(/usr/share/zsh/site-functions $fpath) autoload -Uz compinit && compinit Fixes #2015
This commit is contained in:
@@ -121,6 +121,25 @@ nfpms:
|
||||
file_info:
|
||||
mode: 0700
|
||||
|
||||
- src: extra/versitygw.sh
|
||||
dst: /etc/profile.d/versitygw.sh
|
||||
packager: rpm
|
||||
|
||||
- src: extra/versitygw.sh
|
||||
dst: /etc/bash_completion.d/versitygw.sh
|
||||
packager: deb
|
||||
|
||||
- src: extra/versitygw.zsh
|
||||
dst: /usr/share/zsh/site-functions/_versitygw
|
||||
packager: rpm
|
||||
|
||||
- src: extra/versitygw.zsh
|
||||
dst: /usr/share/zsh/vendor-completions/_versitygw
|
||||
packager: deb
|
||||
|
||||
- src: extra/versitygw.fish
|
||||
dst: /usr/share/fish/vendor_completions.d/versitygw.fish
|
||||
|
||||
|
||||
|
||||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
|
||||
|
||||
@@ -146,7 +146,8 @@ func main() {
|
||||
|
||||
func initApp() *cli.App {
|
||||
return &cli.App{
|
||||
Usage: "Versity S3 Gateway",
|
||||
EnableBashCompletion: true,
|
||||
Usage: "Versity S3 Gateway",
|
||||
Description: `The Versity S3 Gateway is an S3 protocol translator that allows an S3 client
|
||||
to access the supported backend storage as if it was a native S3 service.
|
||||
VersityGW is an open-source project licensed under the Apache 2.0 License. The
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Fish completion for versitygw
|
||||
function __versitygw_complete
|
||||
set -l cmd (commandline -opc)
|
||||
eval $cmd --generate-bash-completion
|
||||
end
|
||||
complete -f -c versitygw -a '(__versitygw_complete)'
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
# Bash completion for versitygw
|
||||
[ -n "$BASH_VERSION" ] || return 0
|
||||
|
||||
_cli_bash_autocomplete() {
|
||||
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
|
||||
local cur opts
|
||||
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 versitygw
|
||||
@@ -0,0 +1,13 @@
|
||||
#compdef versitygw
|
||||
_versitygw() {
|
||||
local -a opts
|
||||
local cur
|
||||
cur=${words[-1]}
|
||||
if [[ "$cur" == "-"* ]]; then
|
||||
opts=("${(@f)$(${words[1,-2]} ${cur} --generate-bash-completion)}")
|
||||
else
|
||||
opts=("${(@f)$(${words[1,-2]} --generate-bash-completion)}")
|
||||
fi
|
||||
_describe 'versitygw' opts
|
||||
}
|
||||
_versitygw
|
||||
Reference in New Issue
Block a user