mod cli;
mod collection;
mod environment;
mod git_remote;
mod http;
mod hurl;
mod i18n;
mod persistence;
mod postman;
mod request;
mod shared_utils;
mod tree;
mod tui;
mod workspace;
use clap::Parser;
#[derive(Parser)]
#[command(
name = "paperboy",
version,
about = "PaperBoy — a Rust-native API client (a Postman alternative).",
long_about = "PaperBoy — a Rust-native API client (a Postman alternative).\n\n\
Runs in one of three modes:\n\
\x20 TUI (default) a terminal user interface\n\
\x20 CLI (-c/--collection) run a Hurl or Postman collection headlessly, then exit",
after_help = "Examples:\n\
\x20 paperboy Launch the terminal UI (default)\n\
\x20 paperboy -c collection.hurl Run a collection headlessly\n\
\x20 paperboy -c collection.hurl -e environment.vars Run a collection with an environment\n\
\x20 paperboy -c collection.hurl --batch Run as one batch (preserves cookies across requests)\n\n\
Environment (.vars) entries are KEY=value, where the value is a literal or a\n\
{{ ... }} provider reference resolved when the environment is loaded:\n\
\x20 Literal value USERNAME=demo\n\
\x20 Process env var BASE_URL={{ env:DEMO_BASE_URL }}\n\
\x20 1Password (op CLI) API_TOKEN={{ op://Vault/Item/field }}\n\
\x20 AWS SSM parameter DB_PASSWORD={{ ssm:/path/to/param }}\n\n\
Collections are Hurl files (.hurl) or Postman collection exports (.json);\n\
Postman JSON is imported automatically."
)]
struct Cli {
#[arg(short = 'c', long, value_name = "FILE")]
collection: Option<String>,
#[arg(short = 'e', long, value_name = "FILE")]
env: Option<String>,
#[arg(short = 'b', long)]
batch: bool,
}
fn main() {
let cli = Cli::parse();
if let Some(collection) = cli.collection {
std::process::exit(cli::run(collection, cli.env, cli.batch));
}
if let Err(e) = tui::run() {
eprintln!("tui error: {e}");
std::process::exit(1);
}
std::process::exit(0);
}