Skip to content

text() and other prompts not working when stdin is piped #181

@henrywood

Description

@henrywood

Laravel Prompts Version

0.3.3

Laravel Version

11.0

PHP Version

8.2

Operating System & Version

linux ubuntu 22.04

Terminal Application

WSL?

Description

Laravel\Prompts\text() and other functions do not work if something is piped into a process's STDIN pipe (and then read via stream_get_contents(STDIN);

ie

use function Laravel\Prompts\text;

$data = stream_get_contents(STDIN);

$desc = text(   label: 'Description', 
                required: TRUE, 
                placeholder: 'Snippet description',
);

The problem is that NO input field is displayed

If I comment the $data = stream_get_contents(STDIN); line,
the text() works as expected.

Note: I am using laravel/prompts composer package without Laravel !

Steps To Reproduce

use function Laravel\Prompts\text;

$data = stream_get_contents(STDIN);

$desc = text(   label: 'Description', 
                required: TRUE, 
                placeholder: 'Snippet description',
);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions