tools: add help for `v complete` (#13098)

pull/13109/head
Larpon 2022-01-09 15:09:10 +01:00 committed by GitHub
parent b44b8c472d
commit 05ec8ec15b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 0 deletions

View File

@ -44,6 +44,34 @@ import os
const (
auto_complete_shells = ['bash', 'fish', 'zsh', 'powershell'] // list of supported shells
vexe = os.getenv('VEXE')
help_text = "Usage:
v complete [options] [SUBCMD] QUERY...
Description:
Tool for bridging auto completion between various shells and v
Supported shells:
bash, fish, zsh, powershell
Examples:
Echo auto-detected shell install script to STDOUT
v complete
Echo specific shell install script to STDOUT
v complete setup bash
Auto complete input `v tes`*USER PUSHES TAB* (in Bash compatible format).
This is not meant for manual invocation - it's called by the relevant
shell via the script installed with `v complete` or `v complete setup SHELL`.
v complete bash v tes
Options:
-h, --help Show this help text.
SUBCMD:
setup : setup [SHELL] - returns the code for completion setup for SHELL
bash : [QUERY] - returns Bash compatible completion code with completions computed from QUERY
fish : [QUERY] - returns Fish compatible completion code with completions computed from QUERY
zsh : [QUERY] - returns ZSH compatible completion code with completions computed from QUERY
powershell: [QUERY] - returns PowerShell compatible completion code with completions computed from QUERY"
)
// Snooped from cmd/v/v.v, vlib/v/pref/pref.v
@ -289,6 +317,9 @@ fn auto_complete(args []string) {
}
println(lines.join('\n'))
}
'-h', '--help' {
println(help_text)
}
else {}
}
exit(0)

View File

@ -0,0 +1,28 @@
Usage:
v complete [options] [SUBCMD] QUERY...
Description:
Tool for bridging auto completion between various shells and v
Supported shells:
bash, fish, zsh, powershell
Examples:
Echo auto-detected shell install script to STDOUT
v complete
Echo specific shell install script to STDOUT
v complete setup bash
Auto complete input `v tes`*USER PUSHES TAB* (in Bash compatible format).
This is not meant for manual invocation - it's called by the relevant
shell via the script installed with `v complete` or `v complete setup SHELL`.
v complete bash v tes
Options:
-h, --help Show this help text.
SUBCMD:
setup : setup [SHELL] - returns the code for completion setup for SHELL
bash : [QUERY] - returns Bash compatible completion code with completions computed from QUERY
fish : [QUERY] - returns Fish compatible completion code with completions computed from QUERY
zsh : [QUERY] - returns ZSH compatible completion code with completions computed from QUERY
powershell: [QUERY] - returns PowerShell compatible completion code with completions computed from QUERY