Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TAB completion is giving local directory files where command is called. #535

Open
7 tasks done
Karthik1610 opened this issue Jan 16, 2023 · 2 comments
Open
7 tasks done
Labels
question Question or problem

Comments

@Karthik1610
Copy link

Karthik1610 commented Jan 16, 2023

First Check

  • I added a very descriptive title to this issue.
  • 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

#!/usr/bin/env python3
import typer

mgmt_ip_cfg_app = typer.Typer(help="Management Interface Configuration", no_args_is_help=True)

@mgmt_ip_cfg_app.command("Ipv4",
    no_args_is_help=True)
def ipv4_cfg(
            ip: str = typer.Argument(...),
            gateway: str = typer.Argument(...),
            prefixlen: str = typer.Argument(...)):
    pass


@mgmt_ip_cfg_app.command("Ipv6",
    no_args_is_help=True)
def ipv6_cfg(
            ip: str = typer.Argument(...),
            gateway: str = typer.Argument(...),
            prefixlen: str = typer.Argument(...)):
    pass

def main():
    mgmt_ip_cfg_app()

if __name__ == '__main__':
    main()

Description

Hi,

I am new to typer. Kindly point me to doc/issue if this issue is already resolved.
I have written a small cli completion code tmp.py and executed "./tmp.py --install-completion bash".

When i tried to do tab completion , if no files are there tmp.py is repeating "./tmp.py Ipv4 tmp.py tmp.py" or if any files is there, they are getting displayed in the directory where i am calling this script. Could you please help me to resolve this. I am expecting if the last command is reached it should either display help on TAB or dont display anything so that user will enter to get help.

If there are local files, TAB after Ipv4, they are getting displayed.
[root@Linux]# ./tmp.py Ipv4
1       tmp.py

Operating System

Linux

Operating System Details

No response

Typer Version

0.7.0

Python Version

3.6.8

Additional Context

No response

@Karthik1610 Karthik1610 added the question Question or problem label Jan 16, 2023
@relativityhd
Copy link

Hi,
I had the same issue. I had the wrong order of zsh-completion commands in my .zshrc. Try to add this to your .zshrc:

autoload -Uz compinit
zstyle ':completion:*' menu select
fpath+=~/.zfunc
compinit

Thanks @shelper #54 (comment)

@roniel-rhack
Copy link

Same issue, not resolved yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
Projects
None yet
Development

No branches or pull requests

3 participants