- core/framework/flag.sh: flag::define, flag::parse, accessors - core/framework/hook.sh: hook::on, hook::fire, hook::off, hook::has - core/framework/help.sh: help::section, command::help::auto - core/framework/command.sh: command::define, command::route, lazy loading - core restructure: framework/ + app/ separation - load_command: directory-based command detection - command::exists: accepts new-style commands - command::run: routing for new-style, legacy fallback - commands/logs/: migrated to new framework - logs.sh: router + command::define - show.sh: flag::define + flag::parse, no manual case blocks - clean.sh: flag::define + flag::parse - remove.sh: flag::define + flag::parse - rotate.sh: flag::define + flag::parse - logs clean: fix dry_run bool to int conversion - ctx::json_helper: fixed path after core restructure - PYTHONPATH: exported in app/core.sh
30 lines
No EOL
775 B
Bash
30 lines
No EOL
775 B
Bash
#!/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
|
|
} |