Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,44 @@ Use the `--help` option to see more information about the commands and options a
stackql-deploy --help
```

### Tab Completion

**stackql-deploy** supports tab completion for commands and options across multiple shells. To enable tab completion:

#### Bash
Add the following to your `~/.bashrc`:
```bash
eval "$(_STACKQL_DEPLOY_COMPLETE=bash_source stackql-deploy)"
```

#### Zsh
Add the following to your `~/.zshrc`:
```bash
eval "$(_STACKQL_DEPLOY_COMPLETE=zsh_source stackql-deploy)"
```

#### Fish
Add the following to your `~/.config/fish/config.fish`:
```bash
eval (env _STACKQL_DEPLOY_COMPLETE=fish_source stackql-deploy)
```

#### PowerShell
Add the following to your PowerShell profile:
```powershell
Invoke-Expression (& stackql-deploy completion powershell)
```

> **Note:** After adding the completion configuration to your shell's configuration file, restart your terminal or source the configuration file for the changes to take effect.

You can also generate shell-specific completion scripts using:
```bash
stackql-deploy completion bash # for bash
stackql-deploy completion zsh # for zsh
stackql-deploy completion fish # for fish
stackql-deploy completion powershell # for PowerShell
```

## Building and Testing Locally

To get started with **stackql-deploy**, install it locally using pip:
Expand Down
42 changes: 42 additions & 0 deletions stackql_deploy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,47 @@ def upgrade(ctx):
stackql.upgrade()


#
# completion command
#

@cli.command()
@click.argument(
'shell',
type=click.Choice(['bash', 'zsh', 'fish', 'powershell'], case_sensitive=False)
)
def completion(shell):
"""Generate shell completion script for the specified shell.
To enable tab completion, run one of the following:
For bash (add to ~/.bashrc):
eval "$(_STACKQL_DEPLOY_COMPLETE=bash_source stackql-deploy)"
For zsh (add to ~/.zshrc):
eval "$(_STACKQL_DEPLOY_COMPLETE=zsh_source stackql-deploy)"
For fish (add to ~/.config/fish/config.fish):
eval (env _STACKQL_DEPLOY_COMPLETE=fish_source stackql-deploy)
For PowerShell (add to $PROFILE):
Invoke-Expression (& stackql-deploy completion powershell)
"""
shell_lower = shell.lower()

if shell_lower == 'bash':
click.echo('eval "$(_STACKQL_DEPLOY_COMPLETE=bash_source stackql-deploy)"')
elif shell_lower == 'zsh':
click.echo('eval "$(_STACKQL_DEPLOY_COMPLETE=zsh_source stackql-deploy)"')
elif shell_lower == 'fish':
click.echo('eval (env _STACKQL_DEPLOY_COMPLETE=fish_source stackql-deploy)')
elif shell_lower == 'powershell':
click.echo('Register-ArgumentCompleter -Native -CommandName stackql-deploy -ScriptBlock {')
click.echo(' param($wordToComplete, $commandAst, $cursorPosition)')
click.echo(' $env:_STACKQL_DEPLOY_COMPLETE = "complete"')
click.echo(' $env:COMP_WORDS = $commandAst.ToString()')
click.echo(' $env:COMP_CWORD = $cursorPosition')
click.echo(' stackql-deploy | ForEach-Object {')
click.echo(' [System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", $_)')
click.echo(' }')
click.echo('}')


#
# init command
#
Expand Down Expand Up @@ -458,6 +499,7 @@ def init(stack_name, provider):
cli.add_command(init)
cli.add_command(upgrade)
cli.add_command(shell)
cli.add_command(completion)

if __name__ == '__main__':
cli()
Loading