Skip to content

Commit 257818e

Browse files
authored
Add color by default to printing the text format (#1596)
* Add color by default to printing the text format This commit builds on #1593 to provide colorized output of `wasm-tools print`, or any other subcommand that prints the text format, by default. Color settings are controlled on the CLI with `--color` and are automatically disabled in various situations such as outputting to a file or when an output pipe is used. Internally `wasmprinter` has grown a new trait, `Print`, through which all output goes through. There are adapters for this trait for `std::fmt::Write`, `std::io::Write`, and `termcolor::WriteColor`. Custom trait implementations are also possible if necessary. While here I've additionally moved custom custom section printing to the trait itself instead of being part of the printer configuration as it felt more appropriate as a per-sink configuration. * Improve float colors (use comment colors for comments)
1 parent 7003116 commit 257818e

File tree

19 files changed

+457
-221
lines changed

19 files changed

+457
-221
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ libtest-mimic = "0.7.0"
8080
bitflags = "2.5.0"
8181
hashbrown = { version = "0.14.3", default-features = false, features = ['ahash'] }
8282
ahash = { version = "0.8.11", default-features = false }
83+
termcolor = "1.2.0"
8384

8485
wasm-compose = { version = "0.209.1", path = "crates/wasm-compose" }
8586
wasm-encoder = { version = "0.209.1", path = "crates/wasm-encoder" }
@@ -103,7 +104,7 @@ clap = { workspace = true }
103104
clap_complete = { workspace = true, optional = true }
104105
tempfile = "3.2.0"
105106
wat = { workspace = true }
106-
termcolor = "1.2.0"
107+
termcolor = { workspace = true }
107108

108109
# Dependencies of `validate`
109110
wasmparser = { workspace = true, optional = true, features = ['validate'] }

crates/wasmprinter/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ workspace = true
1919
[dependencies]
2020
anyhow = { workspace = true }
2121
wasmparser = { workspace = true, features = ['std'] }
22+
termcolor = { workspace = true }
2223

2324
[dev-dependencies]
2425
diff = "0.1"

0 commit comments

Comments
 (0)