laravel / prompts

Beautiful and user-friendly forms for your command-line PHP applications.
https://laravel.com/docs/prompts
MIT License
504 stars 90 forks source link

Multiple line output for spin #151

Closed jasonvarga closed 3 months ago

jasonvarga commented 3 months ago

Laravel Prompts Version

0.1.23

Laravel Version

11.9.1

PHP Version

8.3.7

Operating System & Version

Ubuntu

Terminal Application

Forge

Description

When using a command with spin() in Forge's deployment script, the output in Forge's logs shows a line for every "frame" of the spin.

image

This doesn't happen when ssh'ing in and running the command manually. The spinner works fine.

I'm not sure where the issue really lies. In our implementation, Laravel's setup of Prompts, or Forge.

Our implementation code is quite simple:

use function Laravel\Prompts\spin;

spin(callback: fn () => Stache::warm(), message: 'Warming the Stache...');

Steps To Reproduce

jbrooksuk commented 3 months ago

This isn't really a bug of Prompts, more a side-effect of how Forge reads the deployment output. During a deployment, Forge pipes output to a file which the CLI reads via the API. Writing to files means that there is no support for the interactive or ANSI codes that replace the spinner in situ.

When running any interactive commands like this, I'd recommend adding the --no-progress or --no-ansi options.

DanielDarrenJones commented 2 months ago

@jbrooksuk --no-progress doesn't seem to be an allowed flag, and --no-ansi doesn't seem to have any affect when testing this in Laravel Forge

jbrooksuk commented 2 months ago

@DanielDarrenJones when you say --no-ansi doesn't have any effect, what happens?

DanielDarrenJones commented 2 months ago

@jbrooksuk image It still outputs the spinner and a new line every time in the deployment log