vito / progrock

progress ui that rocks
Apache License 2.0
62 stars 7 forks source link

using progrock from a non interactive console #13

Open ymolists opened 9 months ago

ymolists commented 9 months ago

Hi folks.

Thank you very much for doing this nice library.

1 ) I am trying to run some tests that involve running progrock in a non iteractive terminal. As in when i am running go tests. So far i have not figured how to do it. Code as the below code seems to not run in a non interactive shell. i keep getting failed with progrock inappropriate ioctl for device. Can you please suggest a workaround ?

    err := progrock.DefaultUI().Run(ctx, writer, it.start)
    if err != nil {
        return err
    }

2) i noticed that in tests located in the concole package you are using an io.Writer. Unfortunately a recorder created like that cannot be passed to progrock.DefaultUI().Run because that is expecting a *Tape. Is there a way around this to make progrock work properly in a non intercatinve shell ? BTW iam able to run all my tests from vscode because vscode supports using an integratedTerminal for running tests. I just cant do that when running tests from the command line so far. This is why i am thinking this has to do with the terminal

vito commented 5 months ago

Hi, sorry, missed the ping for this.

The Tape is meant to run with a TTY, and the console package is meant to be used when a TTY is not available.

They are both a progrock.Writer, which is the unifying interface between them; the idea is that your CLI should detect whether a terminal is present, and plug in whichever is appropriate.

Hope this helps, but given the delay you may have moved on. :)