diff --git a/Cargo.toml b/Cargo.toml index 9001a84..4b54e34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,12 +27,13 @@ tokio = {version = "^1.0", features = ["macros"]} [features] annotate = ["dep:annotate-snippets"] -cli = ["annotate", "color", "dep:clap", "dep:is-terminal", "dep:tokio"] +cli = ["annotate", "color", "dep:clap", "dep:is-terminal", "multi-threaded"] cli-complete = ["cli", "clap_complete"] color = ["annotate-snippets?/color", "dep:termcolor"] default = ["cli", "native-tls"] docker = [] full = ["annotate", "cli-complete", "color", "docker", "unstable"] +multi-threaded = ["dep:tokio"] native-tls = ["reqwest/native-tls"] native-tls-vendored = ["reqwest/native-tls-vendored"] unstable = [] diff --git a/README.md b/README.md index e97f4f3..9da160a 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,7 @@ async fn main() -> Result<(), Box> { - **cli-complete**: Adds commands to generate completion files for various shells. This feature also activates the **cli** feature. Enter `ltrs completions --help` to get help with installing completion files. - **color**: Enables color outputting in the terminal. If **cli** feature is also enable, the `--color=` option will be available. - **full**: Enables all features that are mutually compatible (i.e., `annotate`, `cli`, `cli-complete`, `color`, `docker`, and `unstable`). +- **multi-threaded**: Enables multi-threaded requests. - **native-tls-vendored**: Enables the `vendored` feature of `native-tls`. This or `native-tls` should be activated if you are planning to use HTTPS servers. - **unstable**: Adds more fields to JSON responses that are not present in the [Model | Example Value](https://languagetool.org/http-api/swagger-ui/#!/default/) but might be present in some cases. All added fields are optional, hence the `Option` around them. diff --git a/src/lib/check.rs b/src/lib/check.rs index 9e9d592..0670b36 100644 --- a/src/lib/check.rs +++ b/src/lib/check.rs @@ -9,6 +9,7 @@ use annotate_snippets::{ #[cfg(feature = "cli")] use clap::{Args, Parser, ValueEnum}; use serde::{Deserialize, Serialize}; +#[cfg(feature = "cli")] use std::path::PathBuf; /// Requests @@ -628,7 +629,6 @@ pub struct Context { } /// More context, post-processed in check response. -#[cfg(feature = "cli")] #[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)] #[non_exhaustive] pub struct MoreContext { @@ -1015,7 +1015,6 @@ impl<'source, T> MatchPositions<'source, T> { } fn update_line_number_and_offset(&mut self, m: &Match) { - // TODO: check cases where newline is actually '\r\n' (Windows platforms) let n = m.offset - self.offset; for _ in 0..n { match self.text_chars.next() { diff --git a/src/lib/error.rs b/src/lib/error.rs index 4448ab4..b076aef 100644 --- a/src/lib/error.rs +++ b/src/lib/error.rs @@ -58,6 +58,7 @@ pub enum Error { InvalidFilename(String), /// Error when joining multiple futures. + #[cfg(feature = "multi-threaded")] #[error(transparent)] JoinError(#[from] tokio::task::JoinError), } diff --git a/src/lib/server.rs b/src/lib/server.rs index 9f33ce8..bf9bcc1 100644 --- a/src/lib/server.rs +++ b/src/lib/server.rs @@ -409,6 +409,7 @@ impl ServerClient { /// # Panics /// /// If any of the requests has `self.text` field which is none. + #[cfg(feature = "multi-threaded")] pub async fn check_multiple_and_join( &self, requests: Vec,