#!/usr/bin/env bash # commands/logs/clean.sh function cmd::logs::clean::on_load() { flag::define --force bool "Skip confirmation" flag::define --dry-run bool "Show what would be removed" } function cmd::logs::clean::run() { flag::parse "$@" || return 1 local force=false dry_run=false flag::bool --force && force=true flag::bool --dry-run && dry_run=true local dry_run_flag="0" $dry_run && dry_run_flag="1" local count count=$(json::clean_handshakes \ "$(ctx::events_log)" "$dry_run_flag" 2>/dev/null) || { log::error "Failed to clean handshakes" return 1 } if $dry_run; then log::wg_warning "Dry run — would remove ${count} keepalive handshake(s)" else log::wg_success "Removed ${count} keepalive handshake(s)" fi }