prepare for release

This commit is contained in:
nora 2022-04-28 21:16:43 +02:00
parent 35332a1b26
commit 7aed458197
4 changed files with 30 additions and 14 deletions

View file

@ -1,5 +1,6 @@
# 2.0.0
There are many changes, the two formatting functions have been renamed, `format_reader_writer` now takes
a `W` and `R` instead of `&mut BufReader<W>`, it now always adds a trailing newline. There may be a few more
a `W` and `R` instead of `&mut BufReader<W>`, it now always adds a trailing newline. `Indentation::Default` was
renamed to `Indentation::TwoSpaces` and `FourSpaces` and `Tab` were added. There may be a few more
small changes.

View file

@ -4,27 +4,32 @@
It formats over 20MB of nested JSON in 60ms.
For the library, look at [docs.rs](https://docs.rs/jsonformat)
## Library crate
## Install
For the library crate, look at [docs.rs](https://docs.rs/jsonformat)
## Binary Install
You need Rust installed on your system
`cargo install jsonformat-cli`
## Usage
## Binary Usage
```
jsonformat-cli 0.2.0
Nilstrieb <nilstrieb@gmail.com>
Formats JSON extremely fast
USAGE:
jsonformat [OPTIONS] [input]
jsonformat [OPTIONS] [INPUT]
ARGS:
<input> The input file to format
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
<INPUT> The input file
OPTIONS:
-i, --indent <indentation> Set the indentation used (\s for space, \t for tab)
-o, --output <output> The output file for the formatted json
-h, --help Print help information
-i, --indentation <INDENTATION> The indentation, s will replaced by a space and t by a tab.
ss is the default
-o, --output <OUTPUT> The output file
-V, --version Print version information
```
Reads from stdin if no file is supplied.

View file

@ -1,4 +1,4 @@
use std::{fs, io, path::PathBuf};
use std::{fs, path::PathBuf};
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use jsonformat::{format, format_reader_writer, Indentation};

View file

@ -14,8 +14,12 @@ use std::{
/// but nothing is stopping you from doing that.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Indentation<'a> {
/// Use the default indentation, which is two spaces
/// Fast path for two spaces
TwoSpace,
/// Fast path for four spaces
FourSpace,
/// Fast path for tab
Tab,
/// Use a custom indentation String
Custom(&'a str),
}
@ -142,6 +146,12 @@ where
Indentation::TwoSpace => {
writer.write_all(b" ")?;
}
Indentation::FourSpace => {
writer.write_all(b" ")?;
}
Indentation::Tab => {
writer.write_all(b"\t")?;
}
Indentation::Custom(indent) => {
writer.write_all(indent.as_bytes())?;
}