mirror of https://github.com/go-gitea/gitea.git
Improve CLI commands (#34973)
Improve help related commands and flags and add tests Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>pull/35031/head
parent
091b3e696d
commit
4b174e44a8
@ -1,17 +0,0 @@
|
|||||||
Bash and Zsh completion
|
|
||||||
=======================
|
|
||||||
|
|
||||||
From within the gitea root run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
source contrib/autocompletion/bash_autocomplete
|
|
||||||
```
|
|
||||||
|
|
||||||
or for zsh run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
source contrib/autocompletion/zsh_autocomplete
|
|
||||||
```
|
|
||||||
|
|
||||||
These scripts will check if gitea is on the path and if so add autocompletion for `gitea`. Or if not autocompletion will work for `./gitea`.
|
|
||||||
If gitea has been installed as a different program pass in the `PROG` environment variable to set the correct program name.
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
# Heavily inspired by https://github.com/urfave/cli
|
|
||||||
|
|
||||||
_cli_bash_autocomplete() {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -z "$PROG" ] && [ ! "$(command -v gitea &> /dev/null)" ] ; then
|
|
||||||
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete gitea
|
|
||||||
elif [ -z "$PROG" ]; then
|
|
||||||
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete ./gitea
|
|
||||||
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete "$PWD/gitea"
|
|
||||||
else
|
|
||||||
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete "$PROG"
|
|
||||||
unset PROG
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
#compdef ${PROG:=gitea}
|
|
||||||
|
|
||||||
|
|
||||||
# Heavily inspired by https://github.com/urfave/cli
|
|
||||||
|
|
||||||
_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
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -z $PROG ] ; then
|
|
||||||
compdef _cli_zsh_autocomplete gitea
|
|
||||||
else
|
|
||||||
compdef _cli_zsh_autocomplete $(basename $PROG)
|
|
||||||
fi
|
|
||||||
Loading…
Reference in New Issue