Commit fa863df
committed
enhance: enable shell completions
Enable basic shell completions for `bash`, `zsh`, `fish`, and
`powershell` by exposing the `completion` command automatically
generated by Cobra. The command is hidden, so it doesn't show up
in the help text or completions.
```zsh
$ source <(gptscript completion zsh)
$ gptscript --[tab]
-- completions --
--assemble -- Assemble tool to a single artifact, saved to --output ($GPTSCRIPT_ASSEMBLE)
--cache -- Disable caching ($GPTSCRIPT_CACHE)
--cache-dir -- Directory to store cache (default: $XDG_CACHE_HOME/gptscript) ($GPTSCRIPT_CACHE_DIR)
--debug -- Enable debug logging ($GPTSCRIPT_DEBUG)
--dump-state -- Dump the internal execution state to a file ($GPTSCRIPT_DUMP_STATE)
--help -- help for gptscript
--input -- Read input from a file ("-" for stdin) ($GPTSCRIPT_INPUT)
--list-models -- List the models available and exit ($GPTSCRIPT_LIST_MODELS)
--list-tools -- List built-in tools and exit ($GPTSCRIPT_LIST_TOOLS)
--listen-address -- Server listen address ($GPTSCRIPT_LISTEN_ADDRESS)
--openai-api-key -- OpenAI API KEY ($OPENAI_API_KEY)
--openai-api-type -- OpenAI API Type (valid: OPEN_AI, AZURE, AZURE_AD) ($OPENAI_API_TYPE)
--openai-api-version -- OpenAI API Version (for Azure) ($OPENAI_API_VERSION)
--openai-base-url -- OpenAI base URL ($OPENAI_BASE_URL)
--openai-org-id -- OpenAI organization ID ($OPENAI_ORG_ID)
--output -- Save output to a file, or - for stdout ($GPTSCRIPT_OUTPUT)
--quiet -- No output logging ($GPTSCRIPT_QUIET)
--server -- Start server ($GPTSCRIPT_SERVER)
--sub-tool -- Use tool of this name, not the first tool in file ($GPTSCRIPT_SUB_TOOL)
--version -- version for gptscript
```
This implementation produces file path completions for ALL positional and flag args.
Support for customizing completions for individual arguments will
require new features in `github.com/acorn-io/cmd` and should be
addressed in a followup.
Signed-off-by: Nick Hale <4175918+njhale@users.noreply.github.com>1 parent e28e7b7 commit fa863df
1 file changed
+16
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
53 | 68 | | |
54 | 69 | | |
55 | 70 | | |
| |||
0 commit comments