Add terminal TUI and shell completion

This commit is contained in:
Luna 2026-07-08 20:47:58 -07:00
parent a7535cfc56
commit cab60cd633
11 changed files with 612 additions and 0 deletions

View file

@ -208,6 +208,7 @@ def main(argv: list[str] | None = None) -> int:
help="sid for show, event JSON path for test, or '-'")
rules.add_argument("--json", action="store_true", help="emit JSON")
sub.add_parser("web", help="serve the read-only dashboard")
sub.add_parser("tui", help="open the terminal dashboard (curses)")
sub.add_parser("triage", help="classify captured alerts as likely-FP vs review")
sub.add_parser("fim-baseline", help="build the file-integrity baseline")
sub.add_parser("fim-update", help="refresh the FIM baseline (run by the pacman hook)")
@ -249,6 +250,10 @@ def main(argv: list[str] | None = None) -> int:
help="heartbeat staleness threshold (seconds)")
wd.add_argument("--insecure-tls", action="store_true",
help="allow self-signed/untrusted dashboard certificates")
comp = sub.add_parser("completion",
help="print shell completion script for bash or zsh")
comp.add_argument("shell", choices=["bash", "zsh"],
help="shell to generate completion for")
args = parser.parse_args(argv)
cfg = Config.load(args.config)
@ -270,6 +275,9 @@ def main(argv: list[str] | None = None) -> int:
from .web import serve
serve(cfg)
return 0
if args.cmd == "tui":
from .tui import run as run_tui
return run_tui(cfg)
if args.cmd == "triage":
return _cmd_triage(cfg)
if args.cmd in ("fim-baseline", "fim-update"):
@ -301,6 +309,10 @@ def main(argv: list[str] | None = None) -> int:
if args.cmd == "watchdog":
return _cmd_watchdog(cfg, args.url, args.token, args.max_age,
not args.insecure_tls)
if args.cmd == "completion":
from .completion import script
print(script(args.shell), end="")
return 0
return _cmd_run(cfg)