diff --git a/Cargo.toml b/Cargo.toml index 529a9ba..7c736b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ license = "Apache-2.0/MIT" name = "cargo-inspect" readme = "README.md" repository = "https://github.com/mre/cargo-inspect" -version = "0.4.0" +version = "0.5.0" [[bin]] name = "cargo-inspect" diff --git a/README.md b/README.md index d788478..ab90c4c 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ USAGE: FLAGS: -h, --help Prints help information + --plain Don't highlight output -V, --version Prints version information -v, --verbose Print the original code as a comment above the desugared code diff --git a/src/config.rs b/src/config.rs index f3c9780..a90f110 100644 --- a/src/config.rs +++ b/src/config.rs @@ -16,6 +16,10 @@ pub struct Config { /// Print the original code as a comment above the desugared code #[structopt(short = "v", long = "verbose")] pub verbose: bool, + + /// Don't highlight output + #[structopt(long = "plain")] + pub plain: bool, } /// The structopt enum, which serves as an adapter so that the config options diff --git a/src/lib.rs b/src/lib.rs index 147890d..dc0679f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,10 +42,13 @@ pub fn inspect(config: &Config) -> Result<(), InspectError> { let formatted = format(hir.output)?; - let printer = PrettyPrinter::default().language("rust").build()?; - - let header = config.input.to_owned().unwrap_or(env::current_dir()?); - printer.string_with_header(formatted, header.to_string_lossy().to_string())?; + if config.plain { + println!("{}", formatted); + } else { + let printer = PrettyPrinter::default().language("rust").build()?; + let header = config.input.to_owned().unwrap_or(env::current_dir()?); + printer.string_with_header(formatted, header.to_string_lossy().to_string())?; + } Ok(()) }