mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
feat(completion): complete flag values and stop offering file names
Every value completed to file names, because no command registered a completion. Values without a completer now complete nothing, and only path flags (--*-file, --input, --attachment, --asset, --file, --ssh-key, --dir, --cwd) and arguments named file or directory complete paths. --json completes the fields of the command, also after a comma. --host, --user, --remote and -R complete from hosts.yml, Git remotes and the instance. enumFlag and enumValues give a flag one list of values that validation (case-insensitive) and completion share, and instance completers for issues, pull requests, labels, milestones, users, branches, tags, releases, organizations, teams, workflows, runs, secrets and variables are ready for commands to attach. They give up after two seconds, never prompt, retry or refresh an OAuth token, and drop values with control characters. tea completion bash now says to use eval "$(tea completion bash)", because bash 3.2 on macOS cannot source <(...), and names the bash-completion package; the zsh help says to run compinit first. The README matches. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
5 files changed
+1034
-8
No files matched your search
@@ -69,13 +69,14 @@ Alternatively, `tea auth login --host https://your-instance --oauth` authorizes
|
||||
|
||||
### Shell completion
|
||||
|
||||
If you installed from source or the package does not provide the completions with it you can add them yourself with `tea completion <shell>` command. To generate the completions run one of the following commands depending on your shell.
|
||||
If you installed from source or the package does not provide the completions with it you can add them yourself with `tea completion <shell>` command. Completion offers commands, flags, flag values such as `--state` and `--json` fields, and values from your instance such as repositories. Add the line for your shell to its startup file:
|
||||
|
||||
```shell
|
||||
# .bashrc
|
||||
source <(tea completion bash)
|
||||
# ~/.bashrc (on macOS, ~/.bash_profile)
|
||||
eval "$(tea completion bash)"
|
||||
|
||||
# .zshrc
|
||||
# ~/.zshrc, after compinit
|
||||
autoload -U compinit && compinit
|
||||
source <(tea completion zsh)
|
||||
|
||||
# fish
|
||||
@@ -85,6 +86,8 @@ tea completion fish > ~/.config/fish/completions/tea.fish
|
||||
tea completion powershell | Out-String | Invoke-Expression
|
||||
```
|
||||
|
||||
The bash script needs the bash-completion package. On macOS, install `bash-completion` with Homebrew for the system bash 3.2 (or `bash-completion@2` for a Homebrew bash 4.2+), and use `eval` as above: bash 3.2 cannot `source <(...)`. Without `compinit`, zsh reports `command not found: compdef`. `tea completion <shell> --help` shows these steps and how to install the script system-wide.
|
||||
|
||||
### Man Page
|
||||
|
||||
The hidden command `tea man` can be used to generate the `tea` man page.
|
||||
|
||||
Reference in new issue
Block a user