Skip to content

Commit

Permalink
Merge e819930 into 45dc1f1
Browse files Browse the repository at this point in the history
  • Loading branch information
benfdking authored Oct 30, 2024
2 parents 45dc1f1 + e819930 commit a59d038
Showing 1 changed file with 42 additions and 38 deletions.
80 changes: 42 additions & 38 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn main() {
move |path: &Path| ignore_file.is_ignored(path)
};

match cli.command {
let status_code = match cli.command {
Commands::Lint(LintArgs { paths, format }) => {
let mut linter = linter(config, format);
let result = linter.lint_paths(paths, false, &ignorer);
Expand All @@ -83,19 +83,17 @@ fn main() {

eprintln!("The linter processed {count} file(s).");
linter.formatter_mut().unwrap().completion_message();

std::process::exit(
if linter
.formatter()
.unwrap()
.has_fail
.load(std::sync::atomic::Ordering::SeqCst)
{
1
} else {
0
},
)
if linter
.formatter()
.unwrap()
.has_fail
.load(std::sync::atomic::Ordering::SeqCst)
{
1
} else {
0
}

}
Commands::Fix(FixArgs {
paths,
Expand All @@ -117,35 +115,41 @@ fn main() {
.map(|path| path.files.len())
.sum::<usize>();
println!("{} files processed, nothing to fix.", count_files);
return;
}

if !force {
match check_user_input() {
Some(true) => {
eprintln!("Attempting fixes...");
}
Some(false) => return,
None => {
eprintln!("Invalid input, please enter 'Y' or 'N'");
eprintln!("Aborting...");
return;
0
} else {
if !force {
match check_user_input() {
Some(true) => {
eprintln!("Attempting fixes...");
}
Some(false) => return,
None => {
eprintln!("Invalid input, please enter 'Y' or 'N'");
eprintln!("Aborting...");
return;
}
}
}
}

for linted_dir in result.paths {
for mut file in linted_dir.files {
let path = std::mem::take(&mut file.path);
let write_buff = file.fix_string();
std::fs::write(path, write_buff).unwrap();

for linted_dir in result.paths {
for mut file in linted_dir.files {
let path = std::mem::take(&mut file.path);
let write_buff = file.fix_string();
std::fs::write(path, write_buff).unwrap();
}
}

linter.formatter_mut().unwrap().completion_message();
0
}

linter.formatter_mut().unwrap().completion_message();
}
Commands::Lsp => sqruff_lsp::run(),
}
Commands::Lsp => {
sqruff_lsp::run();
0
}
};

std::process::exit(status_code);
}

fn linter(config: FluffConfig, format: Format) -> Linter {
Expand Down

0 comments on commit a59d038

Please sign in to comment.