Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat: add `no_parallel` switch to `harper-cli lint` (#4517)

Andrew Dunbar51b843dc3850
diff --git a/harper-cli/src/lint.rs b/harper-cli/src/lint.rs
index 83f819080..33d7ed483 100644
--- a/harper-cli/src/lint.rs
+++ b/harper-cli/src/lint.rs
@@ -94,6 +94,7 @@ pub struct LintOptions {
pub color: bool,
pub format: OutputFormat,
pub quiet: bool,
+ pub no_parallel: bool,
}
enum ReportStyle {
@@ -192,6 +193,7 @@ pub fn lint(
ref mut only,
dialect,
ref weirpack_inputs,
+ no_parallel,
..
} = lint_options;
@@ -314,7 +316,7 @@ pub fn lint(
)
};
- if input_jobs.len() > 1 {
+ if !no_parallel && input_jobs.len() > 1 {
input_jobs.into_par_iter().map(run_job).collect::<Vec<_>>()
} else {
input_jobs.into_iter().map(run_job).collect::<Vec<_>>()
@@ -409,6 +411,7 @@ fn lint_one_input(
color: _,
format: _,
quiet: _,
+ no_parallel: _,
} = lint_options;
let mut lint_kinds: HashMap<LintKind, usize> = HashMap::new();
diff --git a/harper-cli/src/main.rs b/harper-cli/src/main.rs
index 46719e67d..d71b68b87 100644
--- a/harper-cli/src/main.rs
+++ b/harper-cli/src/main.rs
@@ -1,44 +1,42 @@
#![doc = include_str!("../README.md")]
-use harper_core::spell::{Dictionary, FstDictionary, MutableDictionary, WordId};
-use hashbrown::HashMap;
-use std::collections::BTreeMap;
-use std::fs::File;
-use std::io::{self, BufReader};
-use std::path::PathBuf;
-// use std::sync::Arc;
-use std::{fs, process};
+use std::{
+ collections::BTreeMap,
+ fs::{self, File},
+ io::{self, BufReader},
+ path::PathBuf,
+ process,
+};
use anyhow::anyhow;
use ariadne::{Color, Label, Report, ReportKind, Source};
use clap::{CommandFactory, Parser, ValueHint};
use clap_complete::{Shell, generate};
use dirs::{config_dir, data_local_dir};
-use harper_core::linting::LintGroup;
-use harper_core::parsers::{IsolateEnglish, MarkdownOptions};
-use harper_core::weir::WeirLinter;
use harper_core::{
CharStringExt, Dialect, DictWordMetadata, OrthFlags, Span, TokenKind, TokenStringExt,
+ linting::LintGroup,
+ parsers::{IsolateEnglish, MarkdownOptions},
+ spell::{Dictionary, FstDictionary, MutableDictionary, WordId},
+ weir::WeirLinter,
};
#[cfg(feature = "training")]
use harper_pos_utils::{BrillChunker, BrillTagger, BurnChunkerCpu};
-
use harper_stats::Stats;
+use hashbrown::HashMap;
use serde::Serialize;
use serde_json::Value;
+mod annotate;
mod input;
+mod lint;
+
+use annotate::AnnotationType;
use input::{
AnyInput, InputTrait,
single_input::{SingleInput, SingleInputOptionExt, SingleInputTrait},
};
-
-mod annotate;
-use annotate::AnnotationType;
-
-mod lint;
-use crate::lint::{OutputFormat, lint};
-use lint::LintOptions;
+use lint::{LintOptions, OutputFormat, lint};
/// A debugging tool for the Harper grammar checker.
#[derive(Parser)]
@@ -92,6 +90,9 @@ enum Args {
/// Suppress informational status messages and only output actual lint errors.
#[arg(long)]
quiet: bool,
+ /// Suppress parallel processing of files (for issue #4513).
+ #[arg(long)]
+ no_parallel: bool,
},
/// Parse a provided document and print the detected symbols.
Parse {
@@ -258,6 +259,7 @@ fn main() -> anyhow::Result<()> {
weirpacks,
format,
quiet,
+ no_parallel,
} => {
let dialect = parse_dialect(&dialect_str)
.map_err(|e| anyhow!("Invalid dialect '{}': {}", dialect_str, e))?;
@@ -276,6 +278,7 @@ fn main() -> anyhow::Result<()> {
color,
format,
quiet,
+ no_parallel,
},
user_dict_path,
// TODO workspace_dict_path?