4 releases

0.2.1 Jan 1, 2025
0.2.0 May 17, 2024
0.1.1 Apr 29, 2024
0.1.0 Apr 27, 2024

#42 in Value formatting

Download history 5/week @ 2024-09-18 8/week @ 2024-09-25 2/week @ 2024-10-02 6/week @ 2024-10-09 5/week @ 2024-10-30 9/week @ 2024-11-06 3/week @ 2024-12-04 6/week @ 2024-12-11 169/week @ 2025-01-01

177 downloads per month

MIT license

175KB
347 lines

EDIFACT Formatter

License Crates.io Version

Simple EDI file formatter.

Demo

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
powersh -c "irm https://github.com/zahidkizmaz/edi-format/releases/latest/download/edi-format-installer.ps1 | iex"

Nix Flakes

nix run github:zahidkizmaz/edi-format -- --help

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 Neovim

Neovim: add edi filetype

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

Custom formatter in conform-nvim conform-nvim

  formatters = {
    edi_format = {
      command = "edi-format",
      args = { "-l", "error", "--stdin" },
    },
  },
efm-langserver

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
~37K SLoC