# ecformat
A command line tool to keep files correct in respect of your [EditorConfig](https://editorconfig.org).
The project is currently in an early stage of development, not yet ready for productive usage.
## Supported EditorConfig properties
The current ecformat version targets the version 0.17.2 of EditorConfig.
Only if a property is set in your `.editorconfig` for a file,
ecformat will handle this property on that file during the `check` and the `fix` command.
When processing file contents, the `charset` of your EditorConfig is respected.
If there is no `charset` configured for a file,
ecformat uses `utf-8` as the fallback to process the other properties.
In the section `Disable EditorConfig properties` of the command helps
(see `ecformat help check` or `ecformat help fix`)
you can find options to disable the handling of specific properties.
From the [properties of EditorConfig,](https://spec.editorconfig.org/#supported-pairs)
ecformat currently supports the following ones:
### `charset`
ecformat determines the actual encoding of a file from its content.
If that mismatch the configured one, the `check` has an error at that file
and `fix` converts the content into the configured encoding.
### `end_of_line`
ecformat considers all end of lines in a file.
If not only the configured style is used, the `check` has an error at that file
and `fix` changes all end of lines to the configured style.
## Installation
[](https://codeberg.org/BaumiCoder/ecformat/releases)
You can find the installation options for each version
in the respective [release on Codeberg](https://codeberg.org/BaumiCoder/ecformat/releases).
### Rust Crate
[](https://crates.io/crates/ecformat)
[](https://crates.io/crates/ecformat)
You can install the latest version of the crate from
[crates.io](https://crates.io/crates/ecformat)
```sh
cargo install --locked ecformat
```
Make sure you have the
[cargo bin directory](https://doc.rust-lang.org/cargo/guide/cargo-home.html#directories)
(default is `$HOME/.cargo/bin`) in your `PATH` variable.
If you want to remove ecformat from your machine again, run the following:
```sh
cargo uninstall ecformat
```
It is also possible to use the crate as library in your Rust project
(see [Crate documentation](https://docs.rs/ecformat) for usage details).
If you only use it in your build scripts,
you should add it as a
[build dependency](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#build-dependencies):
```sh
cargo add --build ecformat
```
As alternative to crates.io, you can use the
[ecformat Crate package on Codeberg](https://codeberg.org/BaumiCoder/-/packages/crate/ecformat)
(see there for details).
### Download binary
The binaries of the versions are available for some common platforms
in the [ecformat_bin package on Codeberg](https://codeberg.org/BaumiCoder/-/packages/generic/ecformat_bin).
### Build from source
Another option is to build from source.
If you have [Rust installed](https://rust-lang.org/tools/install),
clone the repository and checkout the version you want to install.
```sh
git checkout tags/vx.y.z
```
For version `x.y.z` or download a source code archive
from the respective [release](https://codeberg.org/BaumiCoder/ecformat/releases).
Make sure you have the
[cargo bin directory](https://doc.rust-lang.org/cargo/guide/cargo-home.html#directories)
(default is `$HOME/.cargo/bin`) in your `PATH` variable.
Then install the crate with the following command inside the repository / unpacked archive:
```sh
cargo install --locked --path .
```
If you want to remove ecformat from your machine again, run the following:
```sh
cargo uninstall ecformat
```
If you only want to create the binary for your platform,
run the following to get it in the directory `target/release`:
```sh
cargo build --locked --release
```
## License
[](https://api.reuse.software/info/codeberg.org/BaumiCoder/ecformat)
The project is licensed under the [Blue Oak Model License 1.0.0](./LICENSES/BlueOak-1.0.0.txt).
A [modern permissive license](https://writing.kemitchell.com/2019/03/09/Deprecation-Notice.html) which is also easier to understand.
You can find a [brief FAQ on the steward's website](https://blueoakcouncil.org/license-faq).
The project uses REUSE for exact license annotations for every file
as some of them have a different license.