|
1 |
| -extern crate term; |
| 1 | +use term::color::{GREEN, RED, WHITE}; |
| 2 | +use term::{Attr, Error, Result}; |
2 | 3 |
|
3 | 4 | fn main() {
|
4 |
| - if let Err(_) = foo() { |
5 |
| - eprintln!("error: Clippy is no longer available via crates.io\n"); |
6 |
| - eprintln!("help: please run `rustup component add clippy` instead"); |
| 5 | + if foo().is_err() { |
| 6 | + eprintln!( |
| 7 | + "error: Clippy is no longer available via crates.io\n\n\ |
| 8 | + help: please run `rustup component add clippy` instead" |
| 9 | + ); |
7 | 10 | }
|
8 | 11 | std::process::exit(1);
|
9 | 12 | }
|
10 | 13 |
|
11 |
| -fn foo() -> Result<(), ()> { |
12 |
| - let mut t = term::stderr().ok_or(())?; |
| 14 | +fn foo() -> Result<()> { |
| 15 | + let mut t = term::stderr().ok_or(Error::NotSupported)?; |
13 | 16 |
|
14 |
| - t.attr(term::Attr::Bold).map_err(|_| ())?; |
15 |
| - t.fg(term::color::RED).map_err(|_| ())?; |
16 |
| - write!(t, "\nerror: ").map_err(|_| ())?; |
| 17 | + t.attr(Attr::Bold)?; |
| 18 | + t.fg(RED)?; |
| 19 | + write!(t, "\nerror: ")?; |
17 | 20 |
|
| 21 | + t.reset()?; |
| 22 | + t.fg(WHITE)?; |
| 23 | + writeln!(t, "Clippy is no longer available via crates.io\n")?; |
18 | 24 |
|
19 |
| - t.reset().map_err(|_| ())?; |
20 |
| - t.fg(term::color::WHITE).map_err(|_| ())?; |
21 |
| - writeln!(t, "Clippy is no longer available via crates.io\n").map_err(|_| ())?; |
| 25 | + t.attr(Attr::Bold)?; |
| 26 | + t.fg(GREEN)?; |
| 27 | + write!(t, "help: ")?; |
22 | 28 |
|
| 29 | + t.reset()?; |
| 30 | + t.fg(WHITE)?; |
| 31 | + write!(t, "please run `")?; |
23 | 32 |
|
24 |
| - t.attr(term::Attr::Bold).map_err(|_| ())?; |
25 |
| - t.fg(term::color::GREEN).map_err(|_| ())?; |
26 |
| - write!(t, "help: ").map_err(|_| ())?; |
| 33 | + t.attr(Attr::Bold)?; |
| 34 | + write!(t, "rustup component add clippy")?; |
27 | 35 |
|
| 36 | + t.reset()?; |
| 37 | + t.fg(WHITE)?; |
| 38 | + writeln!(t, "` instead")?; |
28 | 39 |
|
29 |
| - t.reset().map_err(|_| ())?; |
30 |
| - t.fg(term::color::WHITE).map_err(|_| ())?; |
31 |
| - write!(t, "please run `").map_err(|_| ())?; |
32 |
| - |
33 |
| - t.attr(term::Attr::Bold).map_err(|_| ())?; |
34 |
| - write!(t, "rustup component add clippy").map_err(|_| ())?; |
35 |
| - |
36 |
| - t.reset().map_err(|_| ())?; |
37 |
| - t.fg(term::color::WHITE).map_err(|_| ())?; |
38 |
| - writeln!(t, "` instead").map_err(|_| ())?; |
39 |
| - |
40 |
| - t.reset().map_err(|_| ())?; |
| 40 | + t.reset()?; |
41 | 41 | Ok(())
|
42 | 42 | }
|
0 commit comments