diff options
author | Akshay <[email protected]> | 2021-10-25 17:48:42 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-10-25 17:48:42 +0100 |
commit | cd527e849f0f05735cb1847a158b7104a00ce65c (patch) | |
tree | f04bb1ed6135640fe9d680b6f8ff6f61c30d3b43 /bin | |
parent | 5f0a1e67c64082c848418daa2b51020eb42c5c12 (diff) |
fix minor bug with out-format
Diffstat (limited to 'bin')
-rw-r--r-- | bin/src/config.rs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/bin/src/config.rs b/bin/src/config.rs index 202ff6c..fc4057a 100644 --- a/bin/src/config.rs +++ b/bin/src/config.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use std::{ | 1 | use std::{ |
2 | default::Default, | 2 | default::Default, |
3 | fs, io, | 3 | fmt, fs, io, |
4 | path::{Path, PathBuf}, | 4 | path::{Path, PathBuf}, |
5 | str::FromStr, | 5 | str::FromStr, |
6 | }; | 6 | }; |
@@ -40,8 +40,8 @@ pub struct Check { | |||
40 | ignore: Vec<String>, | 40 | ignore: Vec<String>, |
41 | 41 | ||
42 | /// Output format. | 42 | /// Output format. |
43 | /// Supported values: errfmt, json (on feature flag only) | 43 | /// Supported values: stderr, errfmt, json (on feature flag only) |
44 | #[clap(short = 'o', long, default_value = "OutFormat::StdErr")] | 44 | #[clap(short = 'o', long, default_value_t, parse(try_from_str))] |
45 | pub format: OutFormat, | 45 | pub format: OutFormat, |
46 | } | 46 | } |
47 | 47 | ||
@@ -192,7 +192,6 @@ fn vfs(files: Vec<PathBuf>) -> Result<ReadOnlyVfs, ConfigErr> { | |||
192 | vfs.set_file_contents(&file, data.as_bytes()); | 192 | vfs.set_file_contents(&file, data.as_bytes()); |
193 | } | 193 | } |
194 | Ok(vfs) | 194 | Ok(vfs) |
195 | |||
196 | } | 195 | } |
197 | 196 | ||
198 | #[derive(Debug, Copy, Clone)] | 197 | #[derive(Debug, Copy, Clone)] |
@@ -209,6 +208,21 @@ impl Default for OutFormat { | |||
209 | } | 208 | } |
210 | } | 209 | } |
211 | 210 | ||
211 | impl fmt::Display for OutFormat { | ||
212 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
213 | write!( | ||
214 | f, | ||
215 | "{}", | ||
216 | match self { | ||
217 | #[cfg(feature = "json")] | ||
218 | Self::Json => "json", | ||
219 | Self::Errfmt => "errfmt", | ||
220 | Self::StdErr => "stderr", | ||
221 | } | ||
222 | ) | ||
223 | } | ||
224 | } | ||
225 | |||
212 | impl FromStr for OutFormat { | 226 | impl FromStr for OutFormat { |
213 | type Err = &'static str; | 227 | type Err = &'static str; |
214 | 228 | ||