rexpect icon indicating copy to clipboard operation
rexpect copied to clipboard

Strip ANSI escape codes

Open AndreaOrru opened this issue 5 years ago • 4 comments

Is it possible to leverage https://docs.rs/strip-ansi-escapes/0.1.0/strip_ansi_escapes somehow to strip ANSI escape codes from the output?

AndreaOrru avatar Jun 02 '20 09:06 AndreaOrru

ah, you mean for removing color codes or cursor movements? What's your use case for this? (just wondering, because rexpect can be used for such different use cases)

philippkeller avatar Jun 02 '20 09:06 philippkeller

Yes exactly. I'm building an interactive command prompt and many command outputs are colored, which makes matching text through rexpect difficult.

P.S. This is for my integration tests.

AndreaOrru avatar Jun 02 '20 09:06 AndreaOrru

Sounds like a good use case! Do you have a specific example which could be used to implement and write tests?

philippkeller avatar Jun 06 '20 11:06 philippkeller

Adding to this so it is mentioned somewhere, this also causes issues with Windows ping.exe, which blinks the cursor using escape codes over the R in "Reply from <ip address>". I think being able to toggle escape code stripping would be ideal, as I imagine there could be use for capturing them.

TyPR124 avatar Jun 14 '20 01:06 TyPR124