3 unstable releases

new 0.2.0 May 17, 2024
0.1.1 Apr 29, 2024
0.1.0 Apr 27, 2024

#33 in Value formatting

Download history 354/week @ 2024-04-27 10/week @ 2024-05-04

364 downloads per month

MIT license

18KB
347 lines

EDIFACT Formatter

License Crates.io Version

Simple EDI file formatter.

Installation

Cargo

cargo install edi-format

Shell

Unix
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/zahidkizmaz/edi-format/releases/latest/download/edi-format-installer.sh | sh
Powershell
powershell -c "irm https://github.com/zahidkizmaz/edi-format/releases/latest/download/edi-format-installer.ps1 | iex"

Building from source

Install rust and cargo if you don't have.

git clone https://github.com/zahidkizmaz/edi-format.git
cd edi-format
cargo build --release
./target/release/edi-format --version
edi-format 0.1.0

Usage

Usage: edi-format [OPTIONS] <PATH>

Arguments:
  <PATH>  Path to format

Options:
      --dry-run                Do not modify the file but show formatted content in stdout
  -l, --log-level <LOG_LEVEL>  Log level eg: trace, debug, info, warn, error [default: INFO]
  -h, --help                   Print help
  -V, --version                Print version

Example Usages

Format a file:
$ cat tests/valid_not_formatted.edi
UNA:+.? 'UNB+IATB:1+6XPPC:ZZ+LHPPC:ZZ+940101:0950+1'UNH+1+PAORES:93:1:IA'MSG+1:45'IFT+3+XYZCOMPANY AVAILABILITY'ERC+A7V:1:AMD'IFT+3+NO MORE FLIGHTS'ODI'TVL+240493:1000::1220+FRA+JFK+DL+400+C'PDI++C:3+Y::3+F::1'APD+74C:0:::6++++++6X'TVL+240493:1740::2030+JFK+MIA+DL+081+C'PDI++C:4'APD+EM2:0:1630::6+++++++DA'UNT+13+1'UNZ+1+1'

$ edi-format --dry-run tests/valid_not_formatted.edi
2024-04-27T06:26:09.441402Z  INFO edi_format: Running in dry-run mode
UNA:+.? '
UNB+IATB:1+6XPPC:ZZ+LHPPC:ZZ+940101:0950+1'
UNH+1+PAORES:93:1:IA'
MSG+1:45'
IFT+3+XYZCOMPANY AVAILABILITY'
ERC+A7V:1:AMD'
IFT+3+NO MORE FLIGHTS'
ODI'
TVL+240493:1000::1220+FRA+JFK+DL+400+C'
PDI++C:3+Y::3+F::1'
APD+74C:0:::6++++++6X'
TVL+240493:1740::2030+JFK+MIA+DL+081+C'
PDI++C:4'
APD+EM2:0:1630::6+++++++DA'
UNT+13+1'
UNZ+1+1'%
Format stdin:
$ cat ./tests/valid_formatted.edi | edi-format --stdin
UNA:+.? '
UNB+IATB:1+6XPPC:ZZ+LHPPC:ZZ+940101:0950+1'
UNH+1+PAORES:93:1:IA'
MSG+1:45'
IFT+3+XYZCOMPANY AVAILABILITY'
ERC+A7V:1:AMD'
IFT+3+NO MORE FLIGHTS'
ODI'
TVL+240493:1000::1220+FRA+JFK+DL+400+C'
PDI++C:3+Y::3+F::1'
APD+74C:0:::6++++++6X'
TVL+240493:1740::2030+JFK+MIA+DL+081+C'
PDI++C:4'
APD+EM2:0:1630::6+++++++DA'
UNT+13+1'
UNZ+1+1'%
Format in IDE:
Neovim with efm-langserver

Neovim: add edi filetype

vim.filetype.add({
  extension = { edi = "edi" },
})

Example efm-langserver config

version: 2
tools:
    edi-format: &edi-format
        format-stdin: true
        format-command: 'edi-format -l error --stdin'
languages:
    edi:
        - <<: *edi-format
Reference

https://en.wikipedia.org/wiki/EDIFACT

Dependencies

~2.5MB
~38K SLoC