Skip to content

Commit

Permalink
Document command autocompletion functionality (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopalet authored Jan 30, 2024
1 parent b42ac71 commit 0459c31
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
65 changes: 65 additions & 0 deletions AUTOCOMPLETION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Autocompletion

This guide describes how you can enable command autocompletion for the STACKIT CLI by leveraging the functionality provided the [Cobra](https://github.com/spf13/cobra) framework.

The process may vary depending on the type of shell you are using and your operating system (OS).

You will need to start a new shell for the setup to take effect.

## bash

This process depends on the `bash-completion` package. If you don't have it installed already, you can install it via your OS's package manager.

#### Linux

```shell
stackit completion bash > /etc/bash_completion.d/stackit
```

#### macOS

```shell
stackit completion bash > $(brew --prefix)/etc/bash_completion.d/stackit
```

## zsh

If shell completion is not already enabled in your environment you will need to enable it by executing the following once:

```shell
echo "autoload -U compinit; compinit" >> ~/.zshrc
```

#### Linux

```shell
stackit completion zsh > "${fpath[1]}/_stackit"
```

#### macOS

```shell
stackit completion zsh > $(brew --prefix)/share/zsh/site-functions/_stackit
```

Additionaly, you might also need to run:

```shell
source $(brew --prefix)/share/zsh/site-functions/_stackit >> ~/.zshrc
```

## PowerShell

You can load completions for your current shell session by running:

```shell
stackit completion powershell | Out-String | Invoke-Expression
```

To load completions for every new session, add the output of the above command to your PowerShell profile.

## fish

```shell
stackit completion fish > ~/.config/fish/completions/stackit.fish
```
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Your feedback is appreciated!

## Installation

Please refer to our [installation](./INSTALLATION.md) guide for instructions on how to install and get started using the STACKIT CLI.
Please refer to our [installation guide](./INSTALLATION.md) for instructions on how to install and get started using the STACKIT CLI.

## Usage

Expand Down Expand Up @@ -65,7 +65,7 @@ To authenticate using a service account, run:
$ stackit auth activate-service-account
```

For more details on how to setup authentication using a service account, check our [Authentication guide](./AUTHENTICATION.md)
For more details on how to setup authentication using a service account, check our [authentication guide](./AUTHENTICATION.md).

## Configuration

Expand Down Expand Up @@ -97,13 +97,17 @@ $ stackit config list

You can also edit the configuration file manually.

## Autocompletion

If you wish to setup command autocompletion in your shell for the STACKIT CLI, please refer to our [autocompletion guide](./AUTOCOMPLETION.md).

## Reporting issues

If you encounter any issues or have suggestions for improvements, please reach out to the Developer Tools team or open a ticket through the [STACKIT Help Center](https://support.stackit.cloud/).

## Contribute

Your contribution is welcome! For more details on how to contribute, refer to our [Contribution Guide](./CONTRIBUTION.md).
Your contribution is welcome! For more details on how to contribute, refer to our [contribution guide](./CONTRIBUTION.md).

## License

Expand Down

0 comments on commit 0459c31

Please sign in to comment.