Skip to content

Commit e308fb7

Browse files
authored
Merge pull request #67 from stackql/feature/ja-updates
fix tab completion issues
2 parents 6c11a85 + 9cb488d commit e308fb7

File tree

8 files changed

+641
-47
lines changed

8 files changed

+641
-47
lines changed

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# MANIFEST.in
2+
include LICENSE
23
include README.rst
34
recursive-include stackql_deploy/templates *.template
45
include stackql_deploy/inc/contributors.csv
6+
include shell_completions/*.bash
7+
include shell_completions/*.zsh
8+
include shell_completions/*.fish
9+
include shell_completions/*.ps1

setup.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,28 @@
2222
package_data={
2323
'stackql_deploy': [
2424
'templates/**/*.template', # Include template files recursively
25-
'contributors.csv'
25+
'inc/contributors.csv' # Fixed path for contributors
2626
],
2727
},
2828

29+
# Install shell completion scripts to system share directory
30+
data_files=[
31+
('share/stackql-deploy/completions', [
32+
'shell_completions/stackql-deploy-completion.bash',
33+
'shell_completions/stackql-deploy-completion.zsh',
34+
'shell_completions/stackql-deploy-completion.fish',
35+
'shell_completions/stackql-deploy-completion.ps1',
36+
])
37+
],
38+
2939
include_package_data=True,
3040
install_requires=[
3141
'click',
3242
'python-dotenv',
3343
'jinja2',
34-
'pystackql>=3.6.1',
44+
'pystackql>=3.8.1',
3545
'PyYAML'
36-
],
46+
],
3747
entry_points={
3848
'console_scripts': [
3949
'stackql-deploy = stackql_deploy.cli:cli',

shell_completions/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Shell Completions for stackql-deploy
2+
3+
This directory contains tab completion scripts for various shells.
4+
5+
## Automatic Installation
6+
7+
The easiest way to install completions:
8+
9+
```bash
10+
stackql-deploy completion bash --install # for bash
11+
stackql-deploy completion zsh --install # for zsh
12+
stackql-deploy completion fish --install # for fish
13+
stackql-deploy completion powershell --install # for PowerShell
14+
```
15+
16+
### Activation
17+
18+
To activate immediately (`bash` example shown, similar logic for other shells):
19+
20+
```bash
21+
eval "$(stackql-deploy completion bash)"
22+
```
23+
24+
## Manual Installation
25+
26+
### Bash
27+
28+
```bash
29+
# Add to ~/.bashrc
30+
echo 'eval "$(stackql-deploy completion bash)"' >> ~/.bashrc
31+
source ~/.bashrc
32+
```
33+
34+
### Zsh
35+
36+
```bash
37+
# Add to ~/.zshrc
38+
echo 'eval "$(stackql-deploy completion zsh)"' >> ~/.zshrc
39+
source ~/.zshrc
40+
```
41+
42+
### Fish
43+
44+
```fish
45+
# Add to ~/.config/fish/config.fish
46+
echo 'stackql-deploy completion fish | source' >> ~/.config/fish/config.fish
47+
source ~/.config/fish/config.fish
48+
```
49+
50+
### PowerShell
51+
52+
```powershell
53+
# Add to your PowerShell profile
54+
Add-Content $PROFILE "`n# stackql-deploy completion`n. (stackql-deploy completion powershell)"
55+
. $PROFILE
56+
```
57+
58+
## Files
59+
60+
- `stackql-deploy-completion.bash` - Bash completion script
61+
- `stackql-deploy-completion.zsh` - Zsh completion script
62+
- `stackql-deploy-completion.fish` - Fish completion script
63+
- `stackql-deploy-completion.ps1` - PowerShell completion script
64+
65+
All scripts are static (no Python subprocess calls) for instant performance.
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
_stackql_deploy_completion() {
2+
local cur prev opts base
3+
COMPREPLY=()
4+
cur="${COMP_WORDS[COMP_CWORD]}"
5+
prev="${COMP_WORDS[COMP_CWORD-1]}"
6+
7+
# Main commands
8+
local commands="build test teardown info init upgrade shell completion"
9+
10+
# Common options for build/test/teardown
11+
local common_opts="--log-level --env-file -e --env --dry-run --show-queries --on-failure --custom-registry --download-dir --help"
12+
13+
# Get the command (first non-option argument)
14+
local cmd=""
15+
for ((i=1; i<${#COMP_WORDS[@]}-1; i++)); do
16+
if [[ ${COMP_WORDS[i]} != -* ]]; then
17+
cmd=${COMP_WORDS[i]}
18+
break
19+
fi
20+
done
21+
22+
# Completion logic
23+
case "${cmd}" in
24+
build|test|teardown)
25+
# After command, need stack_dir then stack_env
26+
local args=()
27+
for ((i=2; i<${#COMP_WORDS[@]}-1; i++)); do
28+
if [[ ${COMP_WORDS[i]} != -* ]]; then
29+
args+=("${COMP_WORDS[i]}")
30+
fi
31+
done
32+
33+
if [ ${#args[@]} -eq 0 ]; then
34+
# Complete directory names for stack_dir
35+
compopt -o dirnames
36+
COMPREPLY=( $(compgen -d -- "${cur}") )
37+
elif [ ${#args[@]} -eq 1 ]; then
38+
# Complete common environment names
39+
COMPREPLY=( $(compgen -W "dev staging prod test prd sit uat" -- "${cur}") )
40+
else
41+
# Complete options
42+
COMPREPLY=( $(compgen -W "${common_opts}" -- "${cur}") )
43+
fi
44+
;;
45+
46+
init)
47+
# init <stack_name> [--provider]
48+
case "${prev}" in
49+
--provider)
50+
COMPREPLY=( $(compgen -W "aws google azure" -- "${cur}") )
51+
;;
52+
init)
53+
# Just type the stack name, no completion
54+
;;
55+
*)
56+
COMPREPLY=( $(compgen -W "--provider --help" -- "${cur}") )
57+
;;
58+
esac
59+
;;
60+
61+
completion)
62+
COMPREPLY=( $(compgen -W "bash zsh fish powershell" -- "${cur}") )
63+
;;
64+
65+
info|upgrade|shell)
66+
COMPREPLY=( $(compgen -W "--help --custom-registry --download-dir" -- "${cur}") )
67+
;;
68+
69+
*)
70+
# No command yet, show main commands and global options
71+
if [[ ${cur} == -* ]]; then
72+
COMPREPLY=( $(compgen -W "--help --version" -- "${cur}") )
73+
else
74+
COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
75+
fi
76+
;;
77+
esac
78+
79+
# Handle option arguments
80+
case "${prev}" in
81+
--log-level)
82+
COMPREPLY=( $(compgen -W "DEBUG INFO WARNING ERROR CRITICAL" -- "${cur}") )
83+
return 0
84+
;;
85+
--env-file)
86+
compopt -o default
87+
COMPREPLY=( $(compgen -f -X '!*.env' -- "${cur}") $(compgen -d -- "${cur}") )
88+
return 0
89+
;;
90+
--on-failure)
91+
COMPREPLY=( $(compgen -W "rollback ignore error" -- "${cur}") )
92+
return 0
93+
;;
94+
--custom-registry)
95+
# URL completion - just let user type
96+
return 0
97+
;;
98+
--download-dir)
99+
compopt -o dirnames
100+
COMPREPLY=( $(compgen -d -- "${cur}") )
101+
return 0
102+
;;
103+
esac
104+
105+
return 0
106+
}
107+
108+
complete -F _stackql_deploy_completion stackql-deploy
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# stackql-deploy completions for fish
2+
3+
# Remove any existing completions
4+
complete -c stackql-deploy -e
5+
6+
# Main commands
7+
complete -c stackql-deploy -n "__fish_use_subcommand" -a "build" -d "Create or update resources"
8+
complete -c stackql-deploy -n "__fish_use_subcommand" -a "test" -d "Run test queries for the stack"
9+
complete -c stackql-deploy -n "__fish_use_subcommand" -a "teardown" -d "Teardown a provisioned stack"
10+
complete -c stackql-deploy -n "__fish_use_subcommand" -a "info" -d "Display version information"
11+
complete -c stackql-deploy -n "__fish_use_subcommand" -a "init" -d "Initialize a new project structure"
12+
complete -c stackql-deploy -n "__fish_use_subcommand" -a "upgrade" -d "Upgrade pystackql and stackql binary"
13+
complete -c stackql-deploy -n "__fish_use_subcommand" -a "shell" -d "Launch the stackql shell"
14+
complete -c stackql-deploy -n "__fish_use_subcommand" -a "completion" -d "Install tab completion"
15+
16+
# Common options for build/test/teardown
17+
set -l common_cmds "build test teardown"
18+
19+
# --log-level
20+
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l log-level -d "Set logging level" -a "DEBUG INFO WARNING ERROR CRITICAL"
21+
22+
# --env-file
23+
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l env-file -d "Environment variables file" -r -F
24+
25+
# -e/--env
26+
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -s e -l env -d "Set additional environment variables"
27+
28+
# --dry-run
29+
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l dry-run -d "Perform a dry run"
30+
31+
# --show-queries
32+
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l show-queries -d "Show queries in output logs"
33+
34+
# --on-failure
35+
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l on-failure -d "Action on failure" -a "rollback ignore error"
36+
37+
# --custom-registry
38+
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l custom-registry -d "Custom registry URL"
39+
40+
# --download-dir
41+
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l download-dir -d "Download directory" -r -a "(__fish_complete_directories)"
42+
43+
# --help
44+
complete -c stackql-deploy -n "__fish_seen_subcommand_from $common_cmds" -l help -d "Show help message"
45+
46+
# build/test/teardown positional arguments
47+
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"
48+
49+
# Environment names (for second positional argument)
50+
function __stackql_deploy_needs_env
51+
set -l cmd (commandline -opc)
52+
set -l cmd_count (count $cmd)
53+
# If we have: stackql-deploy build <dir> [<here>]
54+
if test $cmd_count -ge 3
55+
set -l has_opts 0
56+
for arg in $cmd[3..-1]
57+
if string match -q -- '-*' $arg
58+
set has_opts 1
59+
break
60+
end
61+
end
62+
if test $has_opts -eq 0
63+
return 0
64+
end
65+
end
66+
return 1
67+
end
68+
69+
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"
70+
71+
# init command
72+
complete -c stackql-deploy -n "__fish_seen_subcommand_from init" -l provider -d "Specify provider" -a "aws google azure"
73+
complete -c stackql-deploy -n "__fish_seen_subcommand_from init" -l help -d "Show help message"
74+
75+
# completion command
76+
complete -c stackql-deploy -n "__fish_seen_subcommand_from completion" -a "bash zsh fish powershell" -d "Shell type"
77+
complete -c stackql-deploy -n "__fish_seen_subcommand_from completion" -l install -d "Install completion"
78+
complete -c stackql-deploy -n "__fish_seen_subcommand_from completion" -l help -d "Show help message"
79+
80+
# info/upgrade/shell commands
81+
complete -c stackql-deploy -n "__fish_seen_subcommand_from info upgrade shell" -l help -d "Show help message"
82+
complete -c stackql-deploy -n "__fish_seen_subcommand_from info upgrade shell" -l custom-registry -d "Custom registry URL"
83+
complete -c stackql-deploy -n "__fish_seen_subcommand_from info upgrade shell" -l download-dir -d "Download directory" -r -a "(__fish_complete_directories)"

0 commit comments

Comments
 (0)