Closed azriel91 closed 1 year ago
Thank you :bowing_man:.
I'm curious how are you using indicatif in wasm ? is it not currently hard-coded to stdout/stderr, or do you mean you just want it to compile?
Heya, let's answer that in parts:
is it not currently hard-coded to stdout/stderr
not completely! ProgressBar::with_draw_target
lets you pass in any ProgressDrawTarget
, for which you can create a ProgressDrawTarget::term_like
, and use InMemoryTerm
for example.
do you mean you just want it to compile?
it's a start :upside_down_face:
how are you using indicatif in wasm
The smallest usage is to use indicatif
to track state (ETA, progress, message, ..), and read those values and create a custom rendering.
If I wanted the progress bars to be rendered by indicatif
in a WASM app, then one has to:
InMemoryTerm
as described above.tick()
manually to render the terminal (no steady tick, because no threads).ansi_to_html
magic :magic_wand: :smile:
I haven't done the InMemoryTerm
thing yet, but that screenshot is the output of a to-html
converted progress bar output
Hello, thanks for the detailed answer!
If I wanted the progress bars to be rendered by
indicatif
in a WASM app, then one has to:* Use the `InMemoryTerm` as described above. * Call `tick()` manually to render the terminal (no steady tick, because no threads). * Pass the in-memory term string through [`ansi_to_html`](https://docs.rs/ansi-to-html/0.1.3/ansi_to_html/)
Hello, would you be so kind as to expand on this in a bit? I am trying to use indicatif to render within a wasm32 binary intended for use within a terminal.
I've tried building to wasm32-wasi
and wasm32-wasmer-wasi
with the ultimate goal of being POSIX compliant.
Using
clap = { version = "4.4.4", default-features = false, features = ["derive", "std", "help", "usage", "error-context", "suggestions"] }
indicatif = "0.17.7"
Heya, I'm using
indicatif
in a WASM example, and it doesn't initialize whenstd::time::Instant
is used.I've got a branch (https://github.com/console-rs/indicatif/pull/514) where I've toggled to using
instant::Instant
based on the target architecture. Would this be something you're happy to take?