#!/bin/bash

cliShowPeerHelp()
{
    isHeader "LibrePortal Peer Commands"
    echo "Manage named references to other LibrePortal instances."
    echo ""
    echo "peer list"
    echo "    JSON dump of every peer record (id, kind, config, status)."
    echo ""
    echo "peer get <name>"
    echo "    JSON for a single peer."
    echo ""
    echo "peer add <name> backup-channel hostname=<host> [loc_idx=<n>]"
    echo "    Add a friendly label for another LibrePortal whose backups land in"
    echo "    a location this host can see. loc_idx defaults to 'any enabled'."
    echo ""
    echo "peer remove <name>"
    echo "    Delete the local peer record. Doesn't touch the other host or any"
    echo "    backups — just removes the label."
    echo ""
    echo "peer check [name]"
    echo "    Reachability probe. With <name>, checks one; without, all. Updates"
    echo "    the peer's status + last_seen columns."
    echo ""
    echo "peer token"
    echo "    Print THIS host's pairing token. Hand it to another LibrePortal"
    echo "    so it can authorize this host. Symmetric — both sides accept the"
    echo "    other's token to enable bidirectional peer-shell calls."
    echo ""
    echo "peer pair <token> [override-name]"
    echo "    Accept a pairing token. Installs peer-shell, appends to"
    echo "    authorized_keys with forced-command + lockdown options, and"
    echo "    creates a kind=direct-ssh-direct peer row pointing at the"
    echo "    originator."
    echo ""
    echo "peer apps <peer>"
    echo "    Live list of apps the peer has installed (via peer-shell)."
    echo ""
    echo "peer pull <peer> <app> [--no-pre-backup] [--keep-urls]"
    echo "    Pull <app>'s live data from the peer over SSH and replace this"
    echo "    host's copy. Same defaults as 'restore migrate app' (pre-backup"
    echo "    ON, URL rewrite ON) so you can roll back if the pull misbehaves."
    echo ""
    echo "Notes:"
    echo "  • kind=backup-channel (Phase 1/2) and kind=direct-ssh-direct"
    echo "    (Phase 3) are live. kind=direct-ssh-via-relay (Connect blind"
    echo "    relay) waits for Connect itself to ship."
}
