Skip to content

Commit

Permalink
chore(lib): cleaning and new feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jeertmans committed Feb 7, 2023
1 parent 0cbded2 commit 7878ec7
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
- **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=<WHEN>` 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.
Expand Down
3 changes: 1 addition & 2 deletions src/lib/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions src/lib/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CheckRequest>,
Expand Down

0 comments on commit 7878ec7

Please sign in to comment.