diff options
Diffstat (limited to 'bin/src/config.rs')
-rw-r--r-- | bin/src/config.rs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/bin/src/config.rs b/bin/src/config.rs index 07b3f17..d3c3e91 100644 --- a/bin/src/config.rs +++ b/bin/src/config.rs | |||
@@ -65,7 +65,7 @@ pub struct Check { | |||
65 | } | 65 | } |
66 | 66 | ||
67 | impl Check { | 67 | impl Check { |
68 | pub fn vfs(&self) -> Result<ReadOnlyVfs, ConfigErr> { | 68 | pub fn vfs(&self, extra_ignores: &[String]) -> Result<ReadOnlyVfs, ConfigErr> { |
69 | if self.streaming { | 69 | if self.streaming { |
70 | use std::io::{self, BufRead}; | 70 | use std::io::{self, BufRead}; |
71 | let src = io::stdin() | 71 | let src = io::stdin() |
@@ -76,7 +76,8 @@ impl Check { | |||
76 | .join("\n"); | 76 | .join("\n"); |
77 | Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes())) | 77 | Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes())) |
78 | } else { | 78 | } else { |
79 | let ignore = dirs::build_ignore_set(&self.ignore, &self.target, self.unrestricted)?; | 79 | let all_ignores = dbg!([self.ignore.as_slice(), extra_ignores].concat()); |
80 | let ignore = dirs::build_ignore_set(&all_ignores, &self.target, self.unrestricted)?; | ||
80 | let files = dirs::walk_nix_files(ignore, &self.target)?; | 81 | let files = dirs::walk_nix_files(ignore, &self.target)?; |
81 | vfs(files.collect::<Vec<_>>()) | 82 | vfs(files.collect::<Vec<_>>()) |
82 | } | 83 | } |
@@ -117,7 +118,7 @@ pub enum FixOut { | |||
117 | } | 118 | } |
118 | 119 | ||
119 | impl Fix { | 120 | impl Fix { |
120 | pub fn vfs(&self) -> Result<ReadOnlyVfs, ConfigErr> { | 121 | pub fn vfs(&self, extra_ignores: &[String]) -> Result<ReadOnlyVfs, ConfigErr> { |
121 | if self.streaming { | 122 | if self.streaming { |
122 | use std::io::{self, BufRead}; | 123 | use std::io::{self, BufRead}; |
123 | let src = io::stdin() | 124 | let src = io::stdin() |
@@ -128,7 +129,8 @@ impl Fix { | |||
128 | .join("\n"); | 129 | .join("\n"); |
129 | Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes())) | 130 | Ok(ReadOnlyVfs::singleton("<stdin>", src.as_bytes())) |
130 | } else { | 131 | } else { |
131 | let ignore = dirs::build_ignore_set(&self.ignore, &self.target, self.unrestricted)?; | 132 | let all_ignores = [self.ignore.as_slice(), extra_ignores].concat(); |
133 | let ignore = dirs::build_ignore_set(&all_ignores, &self.target, self.unrestricted)?; | ||
132 | let files = dirs::walk_nix_files(ignore, &self.target)?; | 134 | let files = dirs::walk_nix_files(ignore, &self.target)?; |
133 | vfs(files.collect::<Vec<_>>()) | 135 | vfs(files.collect::<Vec<_>>()) |
134 | } | 136 | } |
@@ -260,16 +262,22 @@ impl FromStr for OutFormat { | |||
260 | pub struct ConfFile { | 262 | pub struct ConfFile { |
261 | #[serde(default = "Vec::new")] | 263 | #[serde(default = "Vec::new")] |
262 | disabled: Vec<String>, | 264 | disabled: Vec<String>, |
265 | |||
263 | nix_version: Option<String>, | 266 | nix_version: Option<String>, |
267 | |||
268 | #[serde(default = "Vec::new")] | ||
269 | pub ignore: Vec<String>, | ||
264 | } | 270 | } |
265 | 271 | ||
266 | impl Default for ConfFile { | 272 | impl Default for ConfFile { |
267 | fn default() -> Self { | 273 | fn default() -> Self { |
268 | let disabled = vec![]; | 274 | let disabled = Default::default(); |
269 | let nix_version = None; | 275 | let ignore = Default::default(); |
276 | let nix_version = Default::default(); | ||
270 | Self { | 277 | Self { |
271 | disabled, | 278 | disabled, |
272 | nix_version, | 279 | nix_version, |
280 | ignore, | ||
273 | } | 281 | } |
274 | } | 282 | } |
275 | } | 283 | } |
@@ -298,9 +306,11 @@ impl ConfFile { | |||
298 | let ideal_config = { | 306 | let ideal_config = { |
299 | let disabled = vec![]; | 307 | let disabled = vec![]; |
300 | let nix_version = Some(utils::default_nix_version()); | 308 | let nix_version = Some(utils::default_nix_version()); |
309 | let ignore = vec![".direnv".into()]; | ||
301 | Self { | 310 | Self { |
302 | disabled, | 311 | disabled, |
303 | nix_version, | 312 | nix_version, |
313 | ignore, | ||
304 | } | 314 | } |
305 | }; | 315 | }; |
306 | toml::ser::to_string_pretty(&ideal_config).unwrap() | 316 | toml::ser::to_string_pretty(&ideal_config).unwrap() |