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

No output in combination with callSilent #22

Closed
mpociot opened this issue Aug 1, 2023 · 2 comments
Closed

No output in combination with callSilent #22

mpociot opened this issue Aug 1, 2023 · 2 comments
Assignees
Labels

Comments

@mpociot
Copy link
Contributor

mpociot commented Aug 1, 2023

Laravel Prompts Version

0.1.1

Laravel Version

10.17.0

PHP Version

8.2.8

Operating System & Version

macOS 13.5

Terminal Application

iTerm

Description

Previous calls to $this->callSilent remove any output of the new prompts package.
Removing any $this->callSilent calls fixes the problem.

Even a simple example command as this:

class TestCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'app:test-command';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     */
    public function handle()
    {
            $this->callSilent('about');
            confirm('Is this visible?');
    }
}

When running this command, no output is visible in the terminal but the application is waiting for user input.
Removing the $this->callSilent('about'); call fixes the issue.

Edit:

Manually calling Prompt::setOutput($this->output); also fixes the problem, like this:

$this->callSilent('about');
Prompt::setOutput($this->output);
confirm('Is this visible?');

So I suppose that the callSilent somehow resets Prompt's output interface.

Steps To Reproduce

I created a test repository here: https://github.com/mpociot/prompts-call-silent

To reproduce:

git clone https://github.com/mpociot/prompts-call-silent.git
cd prompts-call-silent
cp .env.example .env
php artisan key:generate
php artisan app:test-command
@jessarcher
Copy link
Member

Hey @mpociot,

Thanks for the repro repo!

So I suppose that the callSilent somehow resets Prompt's output interface.

This is frustratingly correct. Turns out there's a related issue when you use call/callSilent with the --no-interaction option too.

There are a few ways to solve it so I'm just trying to figure out the best approach that doesn't introduce any new issues.

@jessarcher
Copy link
Member

I've created a fix for this at laravel/framework#47929.

This also helped me uncover and fix some other issues. There is still one remaining issue to be aware of where passing --no-interaction to a child command also prevents interactivity in the parent command afterwards, but I should have that one solved soon too.

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

No branches or pull requests

3 participants