🖨️ esc/pos implementation in gleam

docs: update readme

okk.moe 6f593d98 2ea6ecee

verified
+46 -3
+46 -3
README.md
··· 13 13 gleam add escpos@1 14 14 ``` 15 15 16 + ## Usage 17 + 18 + ### Declarative API 19 + 20 + The `escpos/document` module provides a high-level declarative API: 21 + 16 22 ```gleam 17 - import escpos 23 + import escpos/document.{bold, cut, justify, styled, writeln, Center} 24 + import escpos/printer 25 + 26 + pub fn main() { 27 + let assert Ok(printer) = printer.connect("192.168.1.100", 9100) 28 + 29 + document.build([ 30 + styled([justify(Center), bold()], [ 31 + writeln("Receipt"), 32 + ]), 33 + writeln("Item 1 ... $5.00"), 34 + writeln("Item 2 ... $3.50"), 35 + cut(), 36 + ]) 37 + |> printer.print(printer) 38 + } 39 + ``` 40 + 41 + ### Imperative API 18 42 19 - pub fn main() -> Nil { 20 - // TODO: An example of the project in use 43 + The `escpos` module provides a lower-level builder-style API: 44 + 45 + ```gleam 46 + import escpos.{Center, Left} 47 + import escpos/printer 48 + 49 + pub fn main() { 50 + let assert Ok(printer) = printer.connect("192.168.1.100", 9100) 51 + 52 + escpos.new() 53 + |> escpos.reset() 54 + |> escpos.set_align(Center) 55 + |> escpos.set_bold(True) 56 + |> escpos.writeln("Receipt") 57 + |> escpos.set_bold(False) 58 + |> escpos.set_align(Left) 59 + |> escpos.writeln("Item 1 ... $5.00") 60 + |> escpos.writeln("Item 2 ... $3.50") 61 + |> escpos.line_feed(3) 62 + |> escpos.cut() 63 + |> printer.print(printer) 21 64 } 22 65 ``` 23 66