Skip to content

click and rich prompts interweave into system command prompt #46

@apeaveysf

Description

@apeaveysf

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions