rust-cli / rexpect

.github/workflows/ci.yml
https://docs.rs/rexpect
MIT License
328 stars 56 forks source link

Strip ANSI escape codes #25

Closed AndreaOrru closed 1 year ago

AndreaOrru commented 4 years ago

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?

philippkeller commented 4 years ago

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)

AndreaOrru commented 4 years ago

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.

philippkeller commented 4 years ago

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

TyPR124 commented 4 years ago

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.