ferry-cli 0.1.20

The ferry command for terminal-native LAN file transfer with QUIC, discovery, resume, TUI, and JSON output.
Documentation
use std::process::Command;

#[test]
fn root_help_includes_scriptable_examples_and_stable_nouns() {
    let output = ferry_command()
        .arg("--help")
        .output()
        .expect("ferry --help runs");

    assert!(output.status.success());
    assert!(
        output.stderr.is_empty(),
        "help should not write stderr: {}",
        String::from_utf8_lossy(&output.stderr)
    );
    let help = String::from_utf8(output.stdout).expect("help is utf8");
    assert!(help.contains("FileFerry moves files and directories"));
    assert!(help.contains("Examples:"));
    assert!(help.contains("ferry recv --listen 0.0.0.0:53318 --dest ~/Downloads/ferry"));
    assert!(help.contains("ferry --json send 192.168.1.42:53318 ./bundle"));
    assert!(help.contains("peer"));
    assert!(help.contains("fingerprint"));
    assert!(help.contains("--no-discovery"));
    assert!(help.contains("--json"));
}

#[test]
fn subcommand_help_documents_non_interactive_transfer_flags() {
    let send = help_for(["send", "--help"]);
    assert!(send.contains("Send files or directories to a ferry peer"));
    assert!(send.contains("--fingerprint <FINGERPRINT>"));
    assert!(send.contains("--psk-file <FILE>"));
    assert!(send.contains("192.168.1.42:53318"));

    let recv = help_for(["recv", "--help"]);
    assert!(recv.contains("Receive one transfer in the foreground"));
    assert!(recv.contains("--accept-all"));
    assert!(recv.contains("--dest <DIR>"));
    assert!(recv.contains("--psk-file <FILE>"));

    let daemon = help_for(["daemon", "--help"]);
    assert!(daemon.contains("Run a long-lived receiver"));
    assert!(daemon.contains("--listen <LISTEN>"));
    assert!(daemon.contains("--dest <DIR>"));
}

#[test]
fn invalid_peer_address_exits_with_documented_peer_lookup_code() {
    let output = ferry_command()
        .args(["--no-discovery", "send", "127.0.0.1", "missing.txt"])
        .output()
        .expect("ferry send runs");

    assert_eq!(output.status.code(), Some(2));
    assert!(output.stdout.is_empty());
    let stderr = String::from_utf8(output.stderr).expect("stderr is utf8");
    assert!(stderr.contains("invalid peer address"));
}

fn help_for<const N: usize>(args: [&str; N]) -> String {
    let output = ferry_command().args(args).output().expect("help runs");
    assert!(output.status.success());
    String::from_utf8(output.stdout).expect("help is utf8")
}

fn ferry_command() -> Command {
    Command::new(env!("CARGO_BIN_EXE_ferry"))
}