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

click and rich prompts interweave into system command prompt #46

Open
apeaveysf opened this issue Jun 20, 2023 · 4 comments
Open

click and rich prompts interweave into system command prompt #46

apeaveysf opened this issue Jun 20, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@apeaveysf
Copy link

apeaveysf commented Jun 20, 2023

System: Windows 10 (have not tried on Linux yet).
Terminal: Windows Terminal set to Command Prompt.

When using @click.option with a prompt, the command prompt appears to interweave with the running program.
Also occurs when using click.prompt() or rich's Prompt.ask() inside of the function definition.

Will cause the command prompt (such as "(venv) C:\py>") to be displayed throughout click prompts while program is running.

Sometimes will treat response to prompt as if trying to run a system command, sometimes will accept prompt input from the command prompt when the click prompt is not the active display.

As an example, the attached screenshot shows one run of a program through trogon, asking for 2 prompt inputs (a staff name, and an email address). The greenish-yellow squares show the command prompt appearing inside of the running trogon program.

No such problems occur when directly running the click program without trogon. No issues occur if provide the option values in trogon and/or bypass prompts inside program. Have tried on several different functions.

tui

EDIT:
Minimal viable product:

mvp.py:

import click

from trogon import tui

@tui()
@click.group()
def cli():
    pass

@click.command()
@click.option('--name', prompt="Name")
def minimal(name):
    """Prompt for a name."""
    pass

cli.add_command(minimal)

if __name__ == '__main__':
    cli()

setup.py:

from setuptools import setup, find_packages

setup(
    name='mvp',
    version='0.1',
    py_modules=['mvp'],
    install_requires=[
        'Click'
    ],
    packages=find_packages(),
    entry_points='''
        [console_scripts]
        mvp=mvp:cli
    ''',
)

Example application run:
image

@darrenburns darrenburns added the bug Something isn't working label Jun 26, 2023
@darrenburns
Copy link
Member

Thanks for the report

I haven't been able to reproduce this on MacOS - so it may be a Windows issue.

Does it only happen on command prompt?

@apeaveysf
Copy link
Author

apeaveysf commented Jun 26, 2023

Thanks for the report

I haven't been able to reproduce this on MacOS - so it may be a Windows issue.

That was all from my work computer.

Just tried on windows 10 on home computer and experienced all the same issues.

Tried from a Linux install and all the problems disappeared.

Can confirm it appears to be a Windows issue.

Edit: all windows attempts were after pip installing . Using Windows Terminal from the windows store (with windows terminal set to use command prompt. I did not attempt using PowerShell)

@timb82
Copy link

timb82 commented Aug 16, 2023

I'm getting same issue on Windows 10 with command line prompt run both as CMD and in Windows terminal.
I've checked in Powershell too and this behavior completely freezez the PS.

@ddsmit
Copy link

ddsmit commented Sep 13, 2023

I can confirm that Windows 10 running Powershell in Windows Terminal has this issue for me too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants