wgctl/commands/logs/rotate.sh
Nuno Duque Nunes a559b73e8e feat: new flag::define syntax, flag::set_constraint
- flag::define: variadic constraint args (key:value) instead of bracket string
- flag::_parse_constraints_from_args: replaces flag::_parse_and_cache
- flag::set_constraint: Option B syntax for post-definition constraints
- choices separator: comma (choices:split,full) — no quoting needed
- guard against empty _CURRENT_COMMAND in exclusive groups lookup
- migrate all commands to new constraint syntax
- add helpful error for unknown constraint args
2026-05-31 00:16:55 +00:00

18 lines
No EOL
581 B
Bash

#!/usr/bin/env bash
# commands/logs/rotate.sh
function cmd::logs::rotate::on_load() {
flag::define --days value "Remove entries older than N days" default:30 type:int min:1 label:days
flag::define --force bool "Skip confirmation"
flag::define --dry-run bool "Show what would be removed"
}
function cmd::logs::rotate::run() {
flag::parse "$@" || return 1
local days; days=$(flag::value --days)
local force=false dry_run=false
flag::bool --force && force=true
flag::bool --dry-run && dry_run=true
cmd::logs::_rotate_impl "$days" "$force" "$dry_run"
}