Bug: panic on `ansi-8bit-escaped`
bbkane opened this issue · comments
Repro
$ RUST_BACKTRACE=full pastel format ansi-8bit-escaped green
thread 'main' panicked at 'internal error: entered unreachable code: Unknown format type', src/cli/commands/format.rs:45:17
stack backtrace:
0: 0x105a57af5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h54942195382ebc43
1: 0x105a6f491 - core::fmt::write::h03a4fdeef33f04e5
2: 0x105a578ab - std::io::Write::write_fmt::h2f54eb7e3d98f93c
3: 0x105a5a803 - std::panicking::default_hook::{{closure}}::h5b49f92bd56be4e7
4: 0x105a5a52f - std::panicking::default_hook::he9bfa0e01e764f9b
5: 0x105a5ae3b - std::panicking::rust_panic_with_hook::hfdce9374aac935e9
6: 0x105a5a9d9 - rust_begin_unwind
7: 0x105a7796f - std::panicking::begin_panic_fmt::ha6a3e14aa30f2a56
8: 0x1059c7e22 - <pastel::commands::format::FormatCommand as pastel::commands::traits::ColorCommand>::run::h35fc1d7f13cb1283
9: 0x1059c51ab - pastel::main::hbec51e02cfeafdb4
10: 0x1059b7906 - std::rt::lang_start::{{closure}}::hb7dc0bae37a6f3f0
11: 0x105a5a8c8 - std::panicking::try::do_call::hdad9ba23601b147d
12: 0x105a5cd7f - __rust_maybe_catch_panic
13: 0x105a4e435 - std::rt::lang_start_internal::h820f58b1bdc07d9f
14: 0x1059c5a39 - main
The type
argument (ansi-8bit-escaped
) is specified by $ pastel format --help
:
ARGS:
<type>
Output format type. Note that the 'ansi-*-escaped' formats print ansi escape sequences
to the terminal that will not be visible unless something else is printed in addition.
[default: hex] [possible values: rgb, rgb-float, hex,
hsl, hsl-hue, hsl-saturation, hsl-lightness, lch,
lch-lightness, lch-chroma, lch-hue, lab, lab-a,
lab-b, luminance, brightness, ansi-8bit, ansi-24bit,
ansi-8bit-escaped, ansi-24bit-escaped, name]
Cause?
cli.rs
provides ansi-8bit-escaped
- see
Line 218 in bb3d2ab
format.rs
is looking for "ansi-8bit-escapecode"
, not ansi-8bit-escaped
- see
pastel/src/cli/commands/format.rs
Line 41 in b4f7c2c
If you pick a preferred name (ansi-8bit-escaped
or ansi-8bit-escapecode
) in a comment here, I'll be happy to submit a PR with the code change. It looks like an easy way to tell myself I can write rust code :)
Thank you for reporting this.
Let's go with escapecode
.
Thank you for the detailed bug report and the quick fix! I tagged a patch release: https://github.com/sharkdp/pastel/releases/tag/v0.7.1