Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Kat March谩n 馃悎
Kat March谩n 馃悎
@zkat@toot.cat  路  activity timestamp last month

I am once again reminded that I should probably do a better job of letting people know that if they use miette, or things that use miette, you can put NO_GRAPHICS=1 in an env var, and instead of drawing fancy graphical diagnostics, miette will automatically drop into a "narratable" renderer that's optimized for screen readers. The output looks like:

oops!
Diagnostic severity: error
Begin snippet for bad_file.rs starting at line 1, column 1

snippet line 1: source
snippet line 2: text
label at line 2, columns 3 to 6: this bit here
snippet line 3: here
diagnostic help: try doing it better next time?
diagnostic code: oops::my::bad

This works for any tool or library using miette unless they're manually messing with renderer settings and preventing this fallback from happening.

#Miette #Rust #RustLang

screenshot of a test for the corresponding graphical version of the diagnostic being shown in the toot
screenshot of a test for the corresponding graphical version of the diagnostic being shown in the toot
screenshot of a test for the corresponding graphical version of the diagnostic being shown in the toot
  • Copy link
  • Flag this post
  • Block
Hans
Hans
@Hans@tuebingen.network replied  路  activity timestamp last month

@zkat Is this environment variable a commonly accepted standard like the NO_COLOR one?

  • Copy link
  • Flag this comment
  • Block
Kat March谩n 馃悎
Kat March谩n 馃悎
@zkat@toot.cat replied  路  activity timestamp last month

@Hans not as far as I know

  • Copy link
  • Flag this comment
  • Block
Sven
Sven
@HeNeArXn@chaos.social replied  路  activity timestamp last month

@zkat that's a very cool feature!

  • Copy link
  • Flag this comment
  • Block
lui x31, .LkleinesFilmr枚llchen
lui x31, .LkleinesFilmr枚llchen
@filmroellchen@chaos.social replied  路  activity timestamp last month

@zkat @ekuber i did not know this! as i'm using custom options in #spcasm , ill check right away if it can still do this (and add tests for it). thanks!!

  • Copy link
  • Flag this comment
  • Block
Kat March谩n 馃悎
Kat March谩n 馃悎
@zkat@toot.cat replied  路  activity timestamp last month

@filmroellchen https://github.com/zkat/miette/blob/df7bcfa17d9c0813286050ee245d5c3d94653f1c/src/handler.rs#L25-L40

basically if you're setting a custom handler hook, you need to make sure it's not forcing graphical. Otherwise, it'll do the proper fallback (see https://github.com/zkat/miette/blob/df7bcfa17d9c0813286050ee245d5c3d94653f1c/src/handler.rs#L344-L354)

You can also use this to do your own logic, such as doing it on NO_COLOR instead of NO_GRAPHICS

  • Copy link
  • Flag this comment
  • Block
lui x31, .LkleinesFilmr枚llchen
lui x31, .LkleinesFilmr枚llchen
@filmroellchen@chaos.social replied  路  activity timestamp last month

@zkat ok it works fine! great feature thanks!

  • Copy link
  • Flag this comment
  • Block
nadja
nadja
@dequbed@mastodon.chaosfield.at replied  路  activity timestamp last month

@zkat that's really cool and a great way to add accessibility to a crate like miette. Thank you!

  • Copy link
  • Flag this comment
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About 路 Code of conduct 路 Privacy 路 Users 路 Instances
Bonfire social 路 1.0.1-beta.2 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct