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
@@ -208,6 +208,7 @@ func TestRootHelpGroupsCommandsAndTopics(t *testing.T) {
|
||||
"\n repo: ",
|
||||
"\nACTIONS COMMANDS\n run: ",
|
||||
"\nADDITIONAL COMMANDS\n admin: ",
|
||||
"\n completion: Generate shell completion scripts\n",
|
||||
"\nALIAS COMMANDS\n co: Alias for \"pr checkout\"\n",
|
||||
"\nHELP TOPICS\n environment: ",
|
||||
"\nFLAGS\n --help Show help for command\n --version Show tea version\n",
|
||||
@@ -302,6 +303,10 @@ func TestHelpTopicsAndUnknownTopics(t *testing.T) {
|
||||
require.EqualError(t, err, want, args)
|
||||
require.Empty(t, out.String(), args)
|
||||
}
|
||||
values, _ := complete(t, deps, out, "help", "e")
|
||||
require.Equal(t, []string{"environment\tEnvironment variables and global flags", "exit-codes\tExit codes used by tea"}, values)
|
||||
values, _ = complete(t, deps, out, "help", "issue", "l")
|
||||
require.Equal(t, []string{"list\tList repository issues"}, values)
|
||||
}
|
||||
|
||||
func TestVerbAndFlagAliases(t *testing.T) {
|
||||
@@ -423,10 +428,6 @@ const (
|
||||
branch rename
|
||||
branch unprotect
|
||||
branch view
|
||||
completion bash
|
||||
completion fish
|
||||
completion powershell
|
||||
completion zsh
|
||||
config get
|
||||
config list
|
||||
config path
|
||||
|
||||
Reference in new issue
Block a user