You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the GitHub search to find a similar issue and didn't find it.
I searched the Typer documentation, with the integrated search.
I already searched in Google "How to X in Typer" and didn't find any information.
I already read and followed all the tutorial in the docs and didn't find an answer.
I already checked if it is not related to Typer but to Click.
Commit to Help
I commit to help with one of those options 👆
Example Code
importtypervalid_names= ["Camila", "Carlos", "Sebastian"]
defcomplete_name(incomplete: str):
completion= []
fornameinvalid_names:
ifname.startswith(incomplete):
completion.append(name)
returncompletiondefmain(
name: str=typer.Option(
"World", help="The name to say hi to.", autocompletion=complete_name
)
):
typer.echo(f"Hello {name}")
if__name__=="__main__":
typer.run(main)
Description
The intro example from the documentation fails in powershell if you start an incomplete name. For example typer ./main.py run --name Ca[TAB][TAB] fails to suggest completions, tho typer ./main.py run --name [TAB][TAB] does.
The powershell completion set args to the full list of arguments including the incomplete word, e.g. args = ['--name', 'Ca'], incomplete='Ca' unlike the bash completion which drops the incomplete word, e.g. args = ['--name'], incomplete='Ca'.
It looks straightforward to use the $cursorPosition
variable to figure out where to truncate the string and take all but the last arg up to that point. I'll experiment and make a PR.
Operating System
Windows
Operating System Details
Windows 11, powershell 7
Typer Version
0.4.0
Python Version
3.7.12
Additional Context
No response
The text was updated successfully, but these errors were encountered:
patricksurry
changed the title
powershell completion incorrectly includes the incomplete parameter in completed word list
powershell completion fails with partial word because it includes the incomplete word with completed args
Feb 22, 2022
First Check
Commit to Help
Example Code
Description
The intro example from the documentation fails in powershell if you start an incomplete name. For example
typer ./main.py run --name Ca[TAB][TAB]
fails to suggest completions, thotyper ./main.py run --name [TAB][TAB]
does.The powershell completion set
args
to the full list of arguments including the incomplete word, e.g.args = ['--name', 'Ca'], incomplete='Ca'
unlike the bash completion which drops the incomplete word, e.g.args = ['--name'], incomplete='Ca'
.It looks straightforward to use the
$cursorPosition
variable to figure out where to truncate the string and take all but the last arg up to that point. I'll experiment and make a PR.
Operating System
Windows
Operating System Details
Windows 11, powershell 7
Typer Version
0.4.0
Python Version
3.7.12
Additional Context
No response
The text was updated successfully, but these errors were encountered: