alibaba/kt-connect

View on GitHub
docs/en-us/cli/completion.md

Summary

Maintainability
Test Coverage
Ktctl Completion
---

Enables autocompletion of commands and arguments for the `ktctl` tool by `Tab` key. Contains 4 sub-commands:

- bash       generates Bash's autocompletion configuration
- zsh        generates Zsh autocompletion configuration
- fish       generates Fish's autocompletion configuration
- powershell generates PowerShell autocompletion configuration

The detailed usage is as follows:

<!-- tabs:start -->

####**bash**

MacOS system:

```bash
ktctl completion bash > /usr/local/etc/bash_completion.d/ktctl
````

Linux system:

```bash
ktctl completion bash > /etc/bash_completion.d/ktctl
````

Effective for all newly opened windows after the command is executed.

#### **zsh**

MacOS system:

```bash
ktctl completion zsh > /usr/local/share/zsh/site-functions/_ktctl
````

Linux system:

```bash
ktctl completion zsh > "${fpath[1]}/_ktctl"
````

Effective for all newly opened windows after the command is executed.

#### **fish**

Effective only for the current shell window:

```bash
ktctl completion fish | source
````

Take effect for all new shell windows:

```bash
ktctl completion fish > ~/.config/fish/completions/ktctl.fish
````

#### **powershell**

Effective only for the current command line window:

```bash
ktctl completion powershell | Out-String | Invoke-Expression
````

If you want to be valid for all windows, you need to add the text content generated by the following command to the PowerShell Profile:

```bash
ktctl completion powershell
````

> For details on how to use PowerShell Profiles, see [PowerShell Documentation](https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/ise/how-to-use-profiles-in-windows-powershell-ise)

<!-- tabs:end -->

The auto-completion function of `ktctl` includes "command completion" and "parameter completion", for example, as follows (where `<tab>` is pressing the TAB key on the keyboard):

- Command completion: enter `ktctl ex<tab>`, it will be automatically completed as `ktctl exchange`
- Parameter completion: enter `ktctl connect --m<tab>`, it will be automatically completed as `ktctl connect --mode`

When there are multiple matching completion results, you can switch between the results by pressing the Tab key continuously.