Skip to content

Commit bd90937

Browse files
committed
fix test
1 parent f408fee commit bd90937

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

commands/subs/dev/all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def all() -> None:
1515
(["black", "--check", "."], "Formatting check"),
1616
(["ruff", "check", "."], "Linting"),
1717
(["mypy", "commands"], "Type checking"),
18-
(["python", "commands/tests/test_cmd_completion.py"], "Completion tests"),
18+
(["python", "tests/commands/test_cmd_completion.py"], "Completion tests"),
1919
(["pytest", "-v"], "Tests"),
2020
]
2121

commands/utils/completion.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -178,54 +178,50 @@ def generate_completion_script(cli_info: dict[str, Any]) -> str:
178178
# First, collect all commands and their structures
179179
all_commands = list(cli_info["subcommands"].keys())
180180

181-
script = (
182-
'''#!/bin/bash
181+
script = f"""#!/bin/bash
183182
# Auto-generated completion script for ehAye™ Core CLI
184183
export _ehaye_cli_completions_loaded=1
185184
186-
_ehaye_cli_completions() {
185+
_ehaye_cli_completions() {{
187186
local cur prev words cword
188187
if [[ -n "$ZSH_VERSION" ]]; then
189-
cur="${COMP_WORDS[COMP_CWORD]}"
190-
prev="${COMP_WORDS[COMP_CWORD-1]}"
191-
words=("${COMP_WORDS[@]}")
188+
cur="${{COMP_WORDS[COMP_CWORD]}}"
189+
prev="${{COMP_WORDS[COMP_CWORD-1]}}"
190+
words=("${{COMP_WORDS[@]}}")
192191
cword=$COMP_CWORD
193192
else
194193
if type _get_comp_words_by_ref &>/dev/null; then
195194
_get_comp_words_by_ref -n : cur prev words cword
196195
else
197-
cur="${COMP_WORDS[COMP_CWORD]}"
198-
prev="${COMP_WORDS[COMP_CWORD-1]}"
199-
words=("${COMP_WORDS[@]}")
196+
cur="${{COMP_WORDS[COMP_CWORD]}}"
197+
prev="${{COMP_WORDS[COMP_CWORD-1]}}"
198+
words=("${{COMP_WORDS[@]}}")
200199
cword=$COMP_CWORD
201200
fi
202201
fi
203202
204203
# Main commands
205-
local commands="'''
206-
+ " ".join(all_commands)
207-
+ """"
204+
local commands="{" ".join(all_commands)}"
208205
209-
if [[ ${cword} -eq 1 ]]; then
210-
COMPREPLY=($(compgen -W "${commands}" -- "${cur}"))
206+
if [[ ${{cword}} -eq 1 ]]; then
207+
COMPREPLY=($(compgen -W "${{commands}}" -- "${{cur}}"))
211208
return 0
212209
fi
213210
214211
# Find the main command
215212
local cmd=""
216213
local cmd_idx=1
217-
for ((i=1; i < ${cword}; i++)); do
218-
if [[ "${words[i]}" != -* ]]; then
219-
cmd="${words[i]}"
214+
for ((i=1; i < ${{cword}}; i++)); do
215+
if [[ "${{words[i]}}" != -* ]]; then
216+
cmd="${{words[i]}}"
220217
cmd_idx=$i
221218
break
222219
fi
223220
done
224221
225222
# Complete based on command
226-
case "${cmd}" in
223+
case "${{cmd}}" in
227224
"""
228-
)
229225

230226
# Generate cases for each command
231227
for cmd_name, cmd_info in cli_info["subcommands"].items():
@@ -236,12 +232,12 @@ def generate_completion_script(cli_info: dict[str, Any]) -> str:
236232
script += "\n ;;\n"
237233

238234
script += """ *)
239-
if [[ "${cur}" == -* ]]; then
240-
COMPREPLY=($(compgen -W "--help" -- "${cur}"))
235+
if [[ "${{cur}}" == -* ]]; then
236+
COMPREPLY=($(compgen -W "--help" -- "${{cur}}"))
241237
fi
242238
;;
243239
esac
244-
}
240+
}}
245241
246242
# Only enable completion for interactive shells
247243
if [[ $- == *i* ]]; then

0 commit comments

Comments
 (0)