diff options
author | Akshat Agarwal <humancalico@disroot.org> | 2020-10-21 16:42:01 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-21 13:12:01 +0200 |
commit | d6c824a6c38e4d443a7f050e2f3b7703f98b2cdc (patch) | |
tree | 838d2bec35c12fba207ba5726cb784333d5d9493 /cli/fmt.rs | |
parent | 0fb39f9176c5bfb6a8cd50addd85d596fe93c459 (diff) |
refactor(cli): use PathBuf instead of String for lint and fmt subcommands (#8042)
Diffstat (limited to 'cli/fmt.rs')
-rw-r--r-- | cli/fmt.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/cli/fmt.rs b/cli/fmt.rs index 452ae20b5..1ebf27900 100644 --- a/cli/fmt.rs +++ b/cli/fmt.rs @@ -32,11 +32,11 @@ const BOM_CHAR: char = '\u{FEFF}'; /// First argument and ignore supports globs, and if it is `None` /// then the current directory is recursively walked. pub async fn format( - args: Vec<String>, + args: Vec<PathBuf>, check: bool, - exclude: Vec<String>, + exclude: Vec<PathBuf>, ) -> Result<(), AnyError> { - if args.len() == 1 && args[0] == "-" { + if args.len() == 1 && args[0].to_string_lossy() == "-" { return format_stdin(check); } // collect all files provided. @@ -232,7 +232,7 @@ fn is_supported(path: &Path) -> bool { } pub fn collect_files( - files: Vec<String>, + files: Vec<PathBuf>, ) -> Result<Vec<PathBuf>, std::io::Error> { let mut target_files: Vec<PathBuf> = vec![]; @@ -242,12 +242,12 @@ pub fn collect_files( is_supported, )); } else { - for arg in files { - let p = PathBuf::from(arg); - if p.is_dir() { - target_files.extend(files_in_subtree(p.canonicalize()?, is_supported)); + for file in files { + if file.is_dir() { + target_files + .extend(files_in_subtree(file.canonicalize()?, is_supported)); } else { - target_files.push(p.canonicalize()?); + target_files.push(file.canonicalize()?); }; } } |