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
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# MANIFEST.in
include LICENSE
include README.rst
recursive-include stackql_deploy/templates *.template
include stackql_deploy/inc/contributors.csv
include shell_completions/*.bash
include shell_completions/*.zsh
include shell_completions/*.fish
include shell_completions/*.ps1
16 changes: 13 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,28 @@
package_data={
'stackql_deploy': [
'templates/**/*.template', # Include template files recursively
'contributors.csv'
'inc/contributors.csv' # Fixed path for contributors
],
},

# Install shell completion scripts to system share directory
data_files=[
('share/stackql-deploy/completions', [
'shell_completions/stackql-deploy-completion.bash',
'shell_completions/stackql-deploy-completion.zsh',
'shell_completions/stackql-deploy-completion.fish',
'shell_completions/stackql-deploy-completion.ps1',
])
],

include_package_data=True,
install_requires=[
'click',
'python-dotenv',
'jinja2',
'pystackql>=3.6.1',
'pystackql>=3.8.1',
'PyYAML'
],
],
entry_points={
'console_scripts': [
'stackql-deploy = stackql_deploy.cli:cli',
Expand Down
65 changes: 65 additions & 0 deletions shell_completions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Shell Completions for stackql-deploy

This directory contains tab completion scripts for various shells.

## Automatic Installation

The easiest way to install completions:

```bash
stackql-deploy completion bash --install # for bash
stackql-deploy completion zsh --install # for zsh
stackql-deploy completion fish --install # for fish
stackql-deploy completion powershell --install # for PowerShell
```

### Activation

To activate immediately (`bash` example shown, similar logic for other shells):

```bash
eval "$(stackql-deploy completion bash)"
```

## Manual Installation

### Bash

```bash
# Add to ~/.bashrc
echo 'eval "$(stackql-deploy completion bash)"' >> ~/.bashrc
source ~/.bashrc
```

### Zsh

```bash
# Add to ~/.zshrc
echo 'eval "$(stackql-deploy completion zsh)"' >> ~/.zshrc
source ~/.zshrc
```

### Fish

```fish
# Add to ~/.config/fish/config.fish
echo 'stackql-deploy completion fish | source' >> ~/.config/fish/config.fish
source ~/.config/fish/config.fish
```

### PowerShell

```powershell
# Add to your PowerShell profile
Add-Content $PROFILE "`n# stackql-deploy completion`n. (stackql-deploy completion powershell)"
. $PROFILE
```

## Files

- `stackql-deploy-completion.bash` - Bash completion script
- `stackql-deploy-completion.zsh` - Zsh completion script
- `stackql-deploy-completion.fish` - Fish completion script
- `stackql-deploy-completion.ps1` - PowerShell completion script

All scripts are static (no Python subprocess calls) for instant performance.
108 changes: 108 additions & 0 deletions shell_completions/stackql-deploy-completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
_stackql_deploy_completion() {
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"

# Main commands
local commands="build test teardown info init upgrade shell completion"

# Common options for build/test/teardown
local common_opts="--log-level --env-file -e --env --dry-run --show-queries --on-failure --custom-registry --download-dir --help"

# Get the command (first non-option argument)
local cmd=""
for ((i=1; i<${#COMP_WORDS[@]}-1; i++)); do
if [[ ${COMP_WORDS[i]} != -* ]]; then
cmd=${COMP_WORDS[i]}
break
fi
done

# Completion logic
case "${cmd}" in
build|test|teardown)
# After command, need stack_dir then stack_env
local args=()
for ((i=2; i<${#COMP_WORDS[@]}-1; i++)); do
if [[ ${COMP_WORDS[i]} != -* ]]; then
args+=("${COMP_WORDS[i]}")
fi
done

if [ ${#args[@]} -eq 0 ]; then
# Complete directory names for stack_dir
compopt -o dirnames
COMPREPLY=( $(compgen -d -- "${cur}") )
elif [ ${#args[@]} -eq 1 ]; then
# Complete common environment names
COMPREPLY=( $(compgen -W "dev staging prod test prd sit uat" -- "${cur}") )
else
# Complete options
COMPREPLY=( $(compgen -W "${common_opts}" -- "${cur}") )
fi
;;

init)
# init <stack_name> [--provider]
case "${prev}" in
--provider)
COMPREPLY=( $(compgen -W "aws google azure" -- "${cur}") )
;;
init)
# Just type the stack name, no completion
;;
*)
COMPREPLY=( $(compgen -W "--provider --help" -- "${cur}") )
;;
esac
;;

completion)
COMPREPLY=( $(compgen -W "bash zsh fish powershell" -- "${cur}") )
;;

info|upgrade|shell)
COMPREPLY=( $(compgen -W "--help --custom-registry --download-dir" -- "${cur}") )
;;

*)
# No command yet, show main commands and global options
if [[ ${cur} == -* ]]; then
COMPREPLY=( $(compgen -W "--help --version" -- "${cur}") )
else
COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
fi
;;
esac

# Handle option arguments
case "${prev}" in
--log-level)
COMPREPLY=( $(compgen -W "DEBUG INFO WARNING ERROR CRITICAL" -- "${cur}") )
return 0
;;
--env-file)
compopt -o default
COMPREPLY=( $(compgen -f -X '!*.env' -- "${cur}") $(compgen -d -- "${cur}") )
return 0
;;
--on-failure)
COMPREPLY=( $(compgen -W "rollback ignore error" -- "${cur}") )
return 0
;;
--custom-registry)
# URL completion - just let user type
return 0
;;
--download-dir)
compopt -o dirnames
COMPREPLY=( $(compgen -d -- "${cur}") )
return 0
;;
esac

return 0
}

complete -F _stackql_deploy_completion stackql-deploy
83 changes: 83 additions & 0 deletions shell_completions/stackql-deploy-completion.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# stackql-deploy completions for fish

# Remove any existing completions
complete -c stackql-deploy -e

# Main commands
complete -c stackql-deploy -n "__fish_use_subcommand" -a "build" -d "Create or update resources"
complete -c stackql-deploy -n "__fish_use_subcommand" -a "test" -d "Run test queries for the stack"
complete -c stackql-deploy -n "__fish_use_subcommand" -a "teardown" -d "Teardown a provisioned stack"
complete -c stackql-deploy -n "__fish_use_subcommand" -a "info" -d "Display version information"
complete -c stackql-deploy -n "__fish_use_subcommand" -a "init" -d "Initialize a new project structure"
complete -c stackql-deploy -n "__fish_use_subcommand" -a "upgrade" -d "Upgrade pystackql and stackql binary"
complete -c stackql-deploy -n "__fish_use_subcommand" -a "shell" -d "Launch the stackql shell"
complete -c stackql-deploy -n "__fish_use_subcommand" -a "completion" -d "Install tab completion"

# Common options for build/test/teardown
set -l common_cmds "build test teardown"

# --log-level
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l log-level -d "Set logging level" -a "DEBUG INFO WARNING ERROR CRITICAL"

# --env-file
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l env-file -d "Environment variables file" -r -F

# -e/--env
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -s e -l env -d "Set additional environment variables"

# --dry-run
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l dry-run -d "Perform a dry run"

# --show-queries
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l show-queries -d "Show queries in output logs"

# --on-failure
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l on-failure -d "Action on failure" -a "rollback ignore error"

# --custom-registry
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l custom-registry -d "Custom registry URL"

# --download-dir
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l download-dir -d "Download directory" -r -a "(__fish_complete_directories)"

# --help
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l help -d "Show help message"

# build/test/teardown positional arguments
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds; and not __fish_seen_argument -l log-level -l env-file -s e -l env -l dry-run -l show-queries -l on-failure -l custom-registry -l download-dir" -a "(__fish_complete_directories)" -d "Stack directory"

# Environment names (for second positional argument)
function __stackql_deploy_needs_env
set -l cmd (commandline -opc)
set -l cmd_count (count $cmd)
# If we have: stackql-deploy build <dir> [<here>]
if test $cmd_count -ge 3
set -l has_opts 0
for arg in $cmd[3..-1]
if string match -q -- '-*' $arg
set has_opts 1
break
end
end
if test $has_opts -eq 0
return 0
end
end
return 1
end

complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds; and __stackql_deploy_needs_env" -a "dev staging prod test prd sit uat" -d "Environment"

# init command
complete -c stackql-deploy -n "__fish_seen_subcommand_from init" -l provider -d "Specify provider" -a "aws google azure"
complete -c stackql-deploy -n "__fish_seen_subcommand_from init" -l help -d "Show help message"

# completion command
complete -c stackql-deploy -n "__fish_seen_subcommand_from completion" -a "bash zsh fish powershell" -d "Shell type"
complete -c stackql-deploy -n "__fish_seen_subcommand_from completion" -l install -d "Install completion"
complete -c stackql-deploy -n "__fish_seen_subcommand_from completion" -l help -d "Show help message"

# info/upgrade/shell commands
complete -c stackql-deploy -n "__fish_seen_subcommand_from info upgrade shell" -l help -d "Show help message"
complete -c stackql-deploy -n "__fish_seen_subcommand_from info upgrade shell" -l custom-registry -d "Custom registry URL"
complete -c stackql-deploy -n "__fish_seen_subcommand_from info upgrade shell" -l download-dir -d "Download directory" -r -a "(__fish_complete_directories)"
Loading
Loading