open-standards/openpay/crates/op-cli/src/main.rs
Transaction Science 70ecd6caa0 Initial import — three open standards under one shelf
Transaction Science open standards monorepo. Each subdirectory is a
self-contained reference protocol with its own README and licence.

- openpay/    Apache-2.0  payment-acceptance stack (Rust, 26 crates)
- smart-byte/ CC-BY-4.0   content-addressed value carrier (spec)
- eoc/        CC-BY-4.0   energy-optimised compute (spec)

The wire format and the right to fork are public. The optional hosted
services are the offer; the protocols are not.
2026-05-23 07:58:09 -04:00

36 lines
1.2 KiB
Rust

//! `op` binary entry point.
//!
//! Parses the [`op_cli::Cli`] via clap, hands it off to
//! [`op_cli::run`], and translates any [`op_cli::Error`] into a
//! human-readable stderr message + exit code 1. Network failures
//! print the canonical "couldn't reach …" message demanded by the
//! spec; non-2xx responses print the response body so operators can
//! see the server's error envelope verbatim.
use std::process::ExitCode;
use clap::Parser;
use op_cli::{Cli, Error, run};
fn main() -> ExitCode {
let cli = Cli::parse();
match run(cli) {
Ok(()) => ExitCode::SUCCESS,
Err(err) => {
match &err {
Error::Network { url, .. } => {
eprintln!("error: couldn't reach {url}");
eprintln!(" {err}");
}
Error::HttpStatus { status, body } => {
eprintln!("error: server returned HTTP {status}");
eprintln!("{body}");
}
Error::BadPayload(msg) => {
eprintln!("error: invalid response payload: {msg}");
}
}
ExitCode::FAILURE
}
}
}