MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / print_flash_warning

Function print_flash_warning

src/global.rs:516–575  ·  view source on GitHub ↗

Prints the big flashing warning shown before a wipe.

(all: bool, targets: &[ProjectStorageLocation])

Source from the content-addressed store, hash-verified

514
515/// Prints the big flashing warning shown before a wipe.
516pub(crate) fn print_flash_warning(all: bool, targets: &[ProjectStorageLocation]) {
517 // Banner is `INNER_WIDTH` display columns wide. The colored title row is
518 // padded with red-background spaces so the highlight reaches the same
519 // width as the `═` rules above and below — a fixed-width visual block
520 // rather than a short red strip floating between long horizontal lines.
521 const INNER_WIDTH: usize = 64;
522 let title = "⚠ DESTRUCTIVE ACTION — TRACEDECAY WIPE ⚠";
523 // Visible columns: ⚠(2) + " "(2) + 36 + " "(2) + ⚠(2) = 44.
524 // Modern terminals render U+26A0 as a 2-col emoji glyph; older terminals
525 // that pick the text presentation will leave a 2-col gap, which is mild.
526 const TITLE_COLS: usize = 44;
527 let pad_total = INNER_WIDTH.saturating_sub(TITLE_COLS);
528 let pad_left = " ".repeat(pad_total / 2);
529 let pad_right = " ".repeat(pad_total - pad_total / 2);
530 let banner = "═".repeat(INNER_WIDTH);
531 let blank_red = " ".repeat(INNER_WIDTH);
532
533 eprintln!();
534 eprintln!("\x1b[1;31m{banner}\x1b[0m");
535 eprintln!("\x1b[1;5;37;41m{blank_red}\x1b[0m");
536 eprintln!("\x1b[1;5;37;41m{pad_left}{title}{pad_right}\x1b[0m");
537 eprintln!("\x1b[1;5;37;41m{blank_red}\x1b[0m");
538 eprintln!("\x1b[1;31m{banner}\x1b[0m");
539 eprintln!();
540 if all {
541 eprintln!(
542 "\x1b[1;31mThis will wipe \x1b[5mALL\x1b[25;1;31m tracked tracedecay projects \
543 AND empty the global DB.\x1b[0m"
544 );
545 } else {
546 eprintln!(
547 "\x1b[1;31mThis will wipe local tracedecay DBs in the current folder \
548 (parents and children).\x1b[0m"
549 );
550 }
551 eprintln!();
552 if targets.is_empty() {
553 eprintln!(" \x1b[33m(no project .tracedecay directories found)\x1b[0m");
554 } else {
555 eprintln!("Targets:");
556 for t in targets {
557 eprintln!(
558 " \x1b[31m✗\x1b[0m {} [{}]",
559 t.data_root.display(),
560 t.status.label()
561 );
562 if let Some(marker_root) = &t.marker_root {
563 eprintln!(" marker: {}", marker_root.display());
564 }
565 }
566 }
567 if all {
568 if let Some(p) = tracedecay::global_db::global_db_path() {
569 eprintln!(" \x1b[31m✗\x1b[0m {} (global DB)", p.display());
570 }
571 }
572 eprintln!();
573 eprintln!("\x1b[1;5;33mThis cannot be undone.\x1b[0m");

Callers 1

handle_wipeFunction · 0.85

Calls 2

global_db_pathFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected