commit - 1f0257d4d8969af8d472921bc67ce67fce21d69e
commit + 69eb0be76963e3aa5eb5d74876a06f6ed741e518
blob - 78300644d9d42baf9d584d7c4797842ba7c81ee8
blob + 1693cd4507d222c600750560861d390748df5a08
--- Cargo.lock
+++ Cargo.lock
]
[[package]]
+name = "ppa6-cups"
+version = "0.1.0"
+dependencies = [
+ "ppa6",
+]
+
+[[package]]
name = "ppa6-gui"
version = "0.1.0"
dependencies = [
blob - f32aebedd1356763aaad4963d1da765b5a917f49
blob + 4a89a4c105fe627d3e6be80e728e0116faa8b601
--- Cargo.toml
+++ Cargo.toml
resolver = "2"
members = [
"ppa6",
+ "ppa6-cups",
"ppa6-gui"
]
blob - /dev/null
blob + 59b21523a478d8104609900fbda77983eefb7a16 (mode 644)
--- /dev/null
+++ ppa6-cups/Cargo.toml
+[package]
+name = "ppa6-cups"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+ppa6 = { path = "../ppa6", version = "0.1.0" }
blob - /dev/null
blob + 65dee1b2bb880aea6ae3a9b2dec3f350b9c23227 (mode 644)
--- /dev/null
+++ ppa6-cups/src/main.rs
+use std::{io::Read, path::PathBuf};
+use ppa6::{usb_context, Document, Printer};
+
+#[derive(Debug)]
+struct Job {
+ id: String,
+ user: String,
+ title: String,
+ num: u32,
+ options: String,
+ path: Option<PathBuf>,
+}
+
+fn parse_cli() -> Option<Job> {
+ let mut args = std::env::args();
+
+ Some(Job {
+ id: args.next()?,
+ user: args.next()?,
+ title: args.next()?,
+ num: args.next()?.parse().ok()?,
+ options: args.next()?,
+ path: args.next().map(PathBuf::from),
+ })
+}
+
+fn main() {
+ let Some(job) = parse_cli() else {
+ eprintln!("usage: ppa6 job_id user job_name ncopies options [file]");
+ std::process::exit(1)
+ };
+
+ dbg!(&job);
+
+ let ctx = usb_context().expect("failed to load libusb");
+ let mut printer = Printer::find(&ctx).expect("no PeriPage A6 found");
+
+ let pixels = match job.path.as_deref() {
+ Some(path) => std::fs::read(path).expect("failed to read file"),
+ None => {
+ let mut buf = Vec::new();
+ std::io::stdin().read_to_end(&mut buf).expect("failed to read stdin");
+ buf
+ }
+ };
+ let doc = Document::new(pixels).expect("failed to create document");
+
+ for _ in 0..job.num {
+ printer.print(&doc, true).expect("failed to print");
+ }
+}