handleRedactCommand function

RedactCommandOutcome handleRedactCommand(
  1. RedactionPipeline? pipeline,
  2. List<String> args
)

Handles a /redact command line against pipeline (null = redaction disabled by config).

Implementation

RedactCommandOutcome handleRedactCommand(
  RedactionPipeline? pipeline,
  List<String> args,
) {
  if (pipeline == null) return RedactCommandOutcome([_disabled]);
  final sub = args.isEmpty ? '' : args.first.toLowerCase();
  return switch (sub) {
    '' => RedactCommandOutcome(['${_statusLine(pipeline)}\n$_usage']),
    'on' || 'off' => _toggleEnabled(pipeline, sub == 'on'),
    'block' => _toggleBlock(pipeline, args),
    'stats' => RedactCommandOutcome(_statsLines(pipeline)),
    'layers' => RedactCommandOutcome(_layerLines(pipeline)),
    _ => RedactCommandOutcome([_usage]),
  };
}