(name: &str, str: &str)
| 43 | } |
| 44 | |
| 45 | pub fn pretty_parse<T>(name: &str, str: &str) -> Result<T, ParserError> |
| 46 | where |
| 47 | T: std::str::FromStr<Err = ParserError>, |
| 48 | { |
| 49 | let str = shellexpand::env(str).map_err(|e| error2(e, 0..0))?; |
| 50 | str.parse::<T>().inspect_err(|e| { |
| 51 | let writer = StandardStream::stderr(term::termcolor::ColorChoice::Auto); |
| 52 | let config = term::Config::default(); |
| 53 | let file = SimpleFile::new(name, str); |
| 54 | term::emit(&mut writer.lock(), &config, &file, &report(e)).unwrap(); |
| 55 | }) |
| 56 | } |