par-term 0.47.0

Cross-platform GPU-accelerated terminal emulator with inline graphics support (Sixel, iTerm2, Kitty)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
//! CLI install, uninstall, and self-update procedure implementations.
//!
//! These functions are invoked by [`super::process_cli`] when the user runs
//! install/uninstall/self-update subcommands. Each follows a
//! prompt-confirm-execute-report pattern; this module and [`super::plugin`]
//! are the only places in the codebase that use blocking stdin reads.

use std::io::{self, Write};

use crate::config::ShellType;
use crate::shader_installer;
use crate::shell_integration_installer;

/// Install shaders from the latest GitHub release (CLI version with prompts and output)
pub fn install_shaders_cli(skip_prompt: bool) -> anyhow::Result<()> {
    let shaders_dir = crate::config::Config::shaders_dir();

    println!("=============================================");
    println!("  par-term Shader Installer");
    println!("=============================================");
    println!();
    println!("Target directory: {}", shaders_dir.display());
    println!();

    // Check if directory has existing shaders
    if shaders_dir.exists() && shader_installer::has_shader_files(&shaders_dir) && !skip_prompt {
        println!("WARNING: This will overwrite existing shaders in:");
        println!("  {}", shaders_dir.display());
        println!();
        print!("Do you want to continue? [y/N] ");
        io::stdout().flush()?;

        let mut response = String::new();
        io::stdin().read_line(&mut response)?;
        let response = response.trim().to_lowercase();

        if response != "y" && response != "yes" {
            println!("Installation cancelled.");
            return Ok(());
        }
        println!();
    }

    // Fetch latest release info
    println!("Fetching latest release information...");

    const REPO: &str = "paulrobello/par-term";
    let api_url = format!("https://api.github.com/repos/{}/releases/latest", REPO);
    let (zip_url, checksum_url) = shader_installer::get_shaders_download_url(&api_url, REPO)
        .map_err(|e| anyhow::anyhow!(e))?;

    println!("Downloading shaders from: {}", zip_url);
    println!();

    // Download the zip file (with optional checksum verification)
    let zip_data = shader_installer::download_and_verify(&zip_url, checksum_url.as_deref())
        .map_err(|e| anyhow::anyhow!(e))?;

    // Create shaders directory if it doesn't exist
    std::fs::create_dir_all(&shaders_dir)?;

    // Extract shaders
    println!("Extracting shaders to {}...", shaders_dir.display());
    shader_installer::extract_shaders(&zip_data, &shaders_dir).map_err(|e| anyhow::anyhow!(e))?;

    // Count installed shaders
    let shader_count = shader_installer::count_shader_files(&shaders_dir);

    println!();
    println!("=============================================");
    println!("  Installation complete!");
    println!("=============================================");
    println!();
    println!("Installed {} shaders to:", shader_count);
    println!("  {}", shaders_dir.display());
    println!();
    println!("To use a shader, add to your config.yaml:");
    println!("  custom_shader: \"shader_name.glsl\"");
    println!("  custom_shader_enabled: true");
    println!();
    println!("For cursor shaders:");
    println!("  cursor_shader: \"cursor_glow.glsl\"");
    println!("  cursor_shader_enabled: true");
    println!();
    println!("See docs/SHADERS.md for the full shader gallery.");

    Ok(())
}

/// Install shell integration for the specified or detected shell (CLI version)
pub fn install_shell_integration_cli(shell: Option<ShellType>) -> anyhow::Result<()> {
    let detected = shell_integration_installer::detected_shell();
    let target_shell = shell.unwrap_or(detected);

    println!("=============================================");
    println!("  par-term Shell Integration Installer");
    println!("=============================================");
    println!();

    if target_shell == ShellType::Unknown {
        eprintln!("Error: Could not detect shell type.");
        eprintln!("Please specify your shell with --shell bash|zsh|fish");
        return Err(anyhow::anyhow!("Unknown shell type"));
    }

    println!("Detected shell: {:?}", target_shell);

    // Check if already installed
    if shell_integration_installer::is_installed() {
        println!("Shell integration is already installed.");
        print!("Do you want to reinstall? [y/N] ");
        io::stdout().flush()?;

        let mut response = String::new();
        io::stdin().read_line(&mut response)?;
        let response = response.trim().to_lowercase();

        if response != "y" && response != "yes" {
            println!("Installation cancelled.");
            return Ok(());
        }
        println!();
    }

    println!("Installing shell integration...");

    match shell_integration_installer::install(Some(target_shell)) {
        Ok(result) => {
            println!();
            println!("=============================================");
            println!("  Installation complete!");
            println!("=============================================");
            println!();
            println!("Script installed to:");
            println!("  {}", result.script_path.display());
            println!();
            println!("Added source line to:");
            println!("  {}", result.rc_file.display());
            println!();
            if result.needs_restart {
                println!("Please restart your shell or run:");
                println!("  source {}", result.rc_file.display());
            }
            Ok(())
        }
        Err(e) => {
            eprintln!("Error: {}", e);
            Err(anyhow::anyhow!(e))
        }
    }
}

/// Uninstall shell integration (CLI version)
pub fn uninstall_shell_integration_cli() -> anyhow::Result<()> {
    println!("=============================================");
    println!("  par-term Shell Integration Uninstaller");
    println!("=============================================");
    println!();

    if !shell_integration_installer::is_installed() {
        println!("Shell integration is not installed.");
        return Ok(());
    }

    println!("Uninstalling shell integration...");

    match shell_integration_installer::uninstall() {
        Ok(result) => {
            println!();
            println!("=============================================");
            println!("  Uninstallation complete!");
            println!("=============================================");
            println!();

            if !result.cleaned.is_empty() {
                println!("Cleaned RC files:");
                for path in &result.cleaned {
                    println!("  {}", path.display());
                }
                println!();
            }

            if !result.scripts_removed.is_empty() {
                println!("Removed integration scripts:");
                for path in &result.scripts_removed {
                    println!("  {}", path.display());
                }
                println!();
            }

            if !result.needs_manual.is_empty() {
                println!("WARNING: Some files need manual cleanup:");
                for path in &result.needs_manual {
                    println!("  {}", path.display());
                }
                println!();
            }

            Ok(())
        }
        Err(e) => {
            eprintln!("Error: {}", e);
            Err(anyhow::anyhow!(e))
        }
    }
}

/// Uninstall shaders using manifest (CLI version)
pub fn uninstall_shaders_cli(force: bool) -> anyhow::Result<()> {
    let shaders_dir = crate::config::Config::shaders_dir();

    println!("=============================================");
    println!("  par-term Shader Uninstaller");
    println!("=============================================");
    println!();
    println!("Shaders directory: {}", shaders_dir.display());
    println!();

    if !shaders_dir.exists() {
        println!("No shaders installed.");
        return Ok(());
    }

    // Check for manifest
    let manifest_path = shaders_dir.join("manifest.json");
    if !manifest_path.exists() {
        println!("No manifest.json found. Cannot determine which files are bundled.");
        println!("Only files installed with the installer can be safely uninstalled.");
        return Err(anyhow::anyhow!("No manifest found"));
    }

    if !force {
        println!("This will remove bundled shader files.");
        println!("User-created and modified files will be preserved.");
        println!();
        print!("Do you want to continue? [y/N] ");
        io::stdout().flush()?;

        let mut response = String::new();
        io::stdin().read_line(&mut response)?;
        let response = response.trim().to_lowercase();

        if response != "y" && response != "yes" {
            println!("Uninstallation cancelled.");
            return Ok(());
        }
        println!();
    }

    println!("Uninstalling shaders...");

    match shader_installer::uninstall_shaders(force) {
        Ok(result) => {
            println!();
            println!("=============================================");
            println!("  Uninstallation complete!");
            println!("=============================================");
            println!();
            println!("Removed {} bundled files.", result.removed);

            if result.kept > 0 {
                println!("Preserved {} user files.", result.kept);
            }

            if !result.needs_confirmation.is_empty() {
                println!();
                println!("Modified files that were preserved:");
                for path in &result.needs_confirmation {
                    println!("  {}", path);
                }
            }

            Ok(())
        }
        Err(e) => {
            eprintln!("Error: {}", e);
            Err(anyhow::anyhow!(e))
        }
    }
}

/// Self-update par-term to the latest version (CLI version)
pub fn self_update_cli(skip_prompt: bool) -> anyhow::Result<()> {
    use par_term_update::self_updater;
    use par_term_update::update_checker;

    println!("=============================================");
    println!("  par-term Self-Updater");
    println!("=============================================");
    println!();

    let current_version = env!("CARGO_PKG_VERSION");
    println!("Current version: {}", current_version);

    // Detect installation type
    let installation = self_updater::detect_installation().map_err(|e| anyhow::anyhow!(e))?;
    println!("Installation type: {}", installation.description());
    println!();

    // Check for managed installations early
    match &installation {
        self_updater::InstallationType::Homebrew => {
            println!("par-term is installed via Homebrew.");
            println!("Please update with:");
            println!("  brew upgrade --cask par-term");
            return Err(anyhow::anyhow!("Cannot self-update Homebrew installation"));
        }
        self_updater::InstallationType::CargoInstall => {
            println!("par-term is installed via cargo.");
            println!("Please update with:");
            println!("  cargo install par-term");
            return Err(anyhow::anyhow!("Cannot self-update cargo installation"));
        }
        _ => {}
    }

    // Check for updates
    println!("Checking for updates...");
    let release_info = update_checker::fetch_latest_release().map_err(|e| anyhow::anyhow!(e))?;

    let latest_version = release_info
        .version
        .strip_prefix('v')
        .unwrap_or(&release_info.version);

    let current = semver::Version::parse(current_version)?;
    let latest = semver::Version::parse(latest_version)?;

    if latest <= current {
        println!();
        println!(
            "You are already running the latest version ({}).",
            current_version
        );
        return Ok(());
    }

    println!();
    println!(
        "New version available: {} -> {}",
        current_version, latest_version
    );
    if let Some(ref notes) = release_info.release_notes {
        println!();
        println!("Release notes:");
        // Show first few lines of release notes
        for line in notes.lines().take(10) {
            println!("  {}", line);
        }
        if notes.lines().count() > 10 {
            println!("  ...");
        }
    }
    println!();

    // Confirm unless --yes
    if !skip_prompt {
        print!("Do you want to update? [y/N] ");
        io::stdout().flush()?;

        let mut response = String::new();
        io::stdin().read_line(&mut response)?;
        let response = response.trim().to_lowercase();

        if response != "y" && response != "yes" {
            println!("Update cancelled.");
            return Ok(());
        }
        println!();
    }

    println!("Downloading and installing update...");

    match self_updater::perform_update(latest_version, crate::VERSION) {
        Ok(result) => {
            println!();
            println!("=============================================");
            println!("  Update complete!");
            println!("=============================================");
            println!();
            println!("Updated: {} -> {}", result.old_version, result.new_version);
            println!("Location: {}", result.install_path.display());
            if result.needs_restart {
                println!();
                println!("Please restart par-term to use the new version.");
            }
            Ok(())
        }
        Err(e) => {
            eprintln!("Update failed: {}", e);
            Err(anyhow::anyhow!(e))
        }
    }
}

/// Install both shaders and shell integration (CLI version)
pub fn install_integrations_cli(skip_prompt: bool) -> anyhow::Result<()> {
    println!("=============================================");
    println!("  par-term Integrations Installer");
    println!("=============================================");
    println!();
    println!("This will install:");
    println!("  1. Shader collection from latest release");
    println!("  2. Shell integration for your current shell");
    println!();

    if !skip_prompt {
        print!("Do you want to continue? [y/N] ");
        io::stdout().flush()?;

        let mut response = String::new();
        io::stdin().read_line(&mut response)?;
        let response = response.trim().to_lowercase();

        if response != "y" && response != "yes" {
            println!("Installation cancelled.");
            return Ok(());
        }
        println!();
    }

    // Install shaders
    println!("Step 1: Installing shaders...");
    println!("---------------------------------------------");

    let shader_result = install_shaders_cli(true);
    if shader_result.is_err() {
        println!();
        println!("WARNING: Shader installation failed.");
        println!("Continuing with shell integration...");
    }

    println!();
    println!("Step 2: Installing shell integration...");
    println!("---------------------------------------------");

    let shell_result = install_shell_integration_cli(None);

    println!();
    println!("=============================================");
    println!("  Integrations Installation Summary");
    println!("=============================================");
    println!();

    match (&shader_result, &shell_result) {
        (Ok(()), Ok(())) => {
            println!("All integrations installed successfully!");
        }
        (Err(_), Ok(())) => {
            println!("Shell integration: INSTALLED");
            println!("Shaders: FAILED (see above for errors)");
        }
        (Ok(()), Err(_)) => {
            println!("Shaders: INSTALLED");
            println!("Shell integration: FAILED (see above for errors)");
        }
        (Err(_), Err(_)) => {
            println!("Both installations failed. See above for errors.");
        }
    }

    // Return success if at least one succeeded
    if shader_result.is_ok() || shell_result.is_ok() {
        Ok(())
    } else {
        Err(anyhow::anyhow!("Both installations failed"))
    }
}

/// Install the par-mux agent-state extensions for pi and omp (CLI version)
pub fn install_mux_extensions_cli(skip_prompt: bool) -> anyhow::Result<()> {
    use crate::mux_extension_installer;

    println!("=============================================");
    println!("  par-term par-mux Extension Installer");
    println!("=============================================");
    println!();
    println!("This installs the par-mux agent-state extension into each");
    println!("installed agent's extension directory:");
    println!(
        "  pi:  {}",
        dir_display(mux_extension_installer::pi_extension_dir())
    );
    println!(
        "  omp: {}",
        dir_display(mux_extension_installer::omp_extension_dir())
    );
    println!();
    println!("An agent that is not installed is reported and skipped.");

    if !skip_prompt {
        println!();
        print!("Do you want to continue? [y/N] ");
        io::stdout().flush()?;

        let mut response = String::new();
        io::stdin().read_line(&mut response)?;
        let response = response.trim().to_lowercase();

        if response != "y" && response != "yes" {
            println!("Installation cancelled.");
            return Ok(());
        }
    }
    println!();

    let pi_result = mux_extension_installer::install_pi_extension();
    report_install("pi", &pi_result);
    let omp_result = mux_extension_installer::install_omp_extension();
    report_install("omp", &omp_result);

    if pi_result.is_ok() || omp_result.is_ok() {
        println!();
        println!("At least one extension installed successfully.");
        Ok(())
    } else {
        println!();
        Err(anyhow::anyhow!("No extension installed (see errors above)"))
    }
}

/// Uninstall the par-mux agent-state extensions (CLI version)
pub fn uninstall_mux_extensions_cli() -> anyhow::Result<()> {
    use crate::mux_extension_installer;

    println!("=============================================");
    println!("  par-term par-mux Extension Uninstaller");
    println!("=============================================");
    println!();

    let pi_result = mux_extension_installer::uninstall_pi_extension();
    report_removal("pi", &pi_result);
    let omp_result = mux_extension_installer::uninstall_omp_extension();
    report_removal("omp", &omp_result);

    println!();
    println!("Done.");
    Ok(())
}

/// Install the par-mux session hooks for config-entry agents (CLI version)
pub fn install_mux_hooks_cli(skip_prompt: bool) -> anyhow::Result<()> {
    use crate::mux_hook_installer;

    println!("=============================================");
    println!("  par-term par-mux Hook Installer");
    println!("=============================================");
    println!();
    println!("This installs the par-mux session hooks. Unlike the pi/omp");
    println!("extensions (a file drop into the agent's directory), these agents");
    println!("have no extension directory: the hook is an ENTRY inside your");
    println!("existing agent config, merged without touching your other settings,");
    println!("comments, or formatting. Reinstalling is a no-op; uninstalling");
    println!("removes only par-term's entries.");
    println!();
    println!("Agents:");
    println!(
        "  claude: {}",
        dir_display(mux_hook_installer::claude_settings_path())
    );
    println!(
        "  codex:  {}",
        dir_display(mux_hook_installer::codex_config_dir())
    );
    println!(
        "  grok:  {}",
        dir_display(mux_hook_installer::grok_config_dir().map(|dir| dir.join("hooks")))
    );
    println!();

    if !skip_prompt {
        println!();
        print!("Do you want to continue? [y/N] ");
        io::stdout().flush()?;

        let mut response = String::new();
        io::stdin().read_line(&mut response)?;
        let response = response.trim().to_lowercase();

        if response != "y" && response != "yes" {
            println!("Installation cancelled.");
            return Ok(());
        }
    }
    println!();

    let claude_result = mux_hook_installer::install_claude_hook();
    match &claude_result {
        Ok(result) if result.settings_changed => {
            println!(
                "claude: hook entry added to {} (script at {})",
                result.settings_path.display(),
                result.hook_path.display()
            );
        }
        Ok(result) => {
            println!(
                "claude: already installed ({} unchanged, script refreshed)",
                result.settings_path.display()
            );
        }
        Err(err) => println!("claude: FAILED — {err}"),
    }

    // codex reads claude-format hooks from hooks.json gated by a
    // `[features] hooks = true` flag in config.toml.
    let codex_result = mux_hook_installer::install_codex_hook();
    match &codex_result {
        Ok(result) => {
            let summary = match (result.hooks_changed, result.config_changed) {
                (true, true) => format!(
                    "hook entry added to {} and features.hooks enabled in {} (script at {})",
                    result.hooks_path.display(),
                    result.config_path.display(),
                    result.hook_path.display()
                ),
                (true, false) => format!(
                    "hook entry added to {} (features.hooks already enabled; script at {})",
                    result.hooks_path.display(),
                    result.hook_path.display()
                ),
                (false, true) => format!(
                    "features.hooks enabled in {} (hook entry already present; script at {})",
                    result.config_path.display(),
                    result.hook_path.display()
                ),
                (false, false) => format!(
                    "already installed ({} unchanged, script refreshed)",
                    result.hooks_path.display()
                ),
            };
            println!("codex:  {summary}");
        }
        Err(err) => println!("codex:  FAILED — {err}"),
    }

    // grok merges every <config>/hooks/*.json, so its arm writes an owned
    // config file instead of merging.
    let grok_result = mux_hook_installer::install_grok_hook();
    match &grok_result {
        Ok(result) => println!(
            "grok:  hook config written to {} (script at {})",
            result.config_path.display(),
            result.hook_path.display()
        ),
        Err(err) => println!("grok:  FAILED — {err}"),
    }

    if claude_result.is_ok() || codex_result.is_ok() || grok_result.is_ok() {
        println!();
        println!("At least one hook installed successfully.");
        Ok(())
    } else {
        println!();
        Err(anyhow::anyhow!("No hook installed (see errors above)"))
    }
}

/// Uninstall the par-mux session hooks (CLI version)
pub fn uninstall_mux_hooks_cli() -> anyhow::Result<()> {
    use crate::mux_hook_installer;

    println!("=============================================");
    println!("  par-term par-mux Hook Uninstaller");
    println!("=============================================");
    println!();

    let claude_result = mux_hook_installer::uninstall_claude_hook();
    match &claude_result {
        Ok(result) => {
            if result.settings_changed {
                println!(
                    "claude: entries removed from {}",
                    result.settings_path.display()
                );
            }
            if result.hook_removed {
                println!("claude: removed {}", result.hook_path.display());
            }
            if !result.settings_changed && !result.hook_removed {
                if result.hook_path.is_file() {
                    println!(
                        "claude: {} exists but is not par-term's (left untouched)",
                        result.hook_path.display()
                    );
                } else {
                    println!("claude: not installed");
                }
            }
        }
        Err(err) => println!("claude: FAILED — {err}"),
    }

    let codex_result = mux_hook_installer::uninstall_codex_hook();
    match &codex_result {
        Ok(result) => {
            if result.hooks_changed {
                println!(
                    "codex:  entries removed from {}",
                    result.hooks_path.display()
                );
            }
            if result.hook_removed {
                println!("codex:  removed {}", result.hook_path.display());
            }
            if !result.hooks_changed && !result.hook_removed {
                if result.hook_path.is_file() {
                    println!(
                        "codex:  {} exists but is not par-term's (left untouched)",
                        result.hook_path.display()
                    );
                } else {
                    println!("codex:  not installed");
                }
            }
            if result.hooks_changed || result.hook_removed {
                println!(
                    "codex:  note: [features] hooks = true left in {} — inert while no hooks remain; remove it manually if unwanted",
                    result.config_path.display()
                );
            }
        }
        Err(err) => println!("codex:  FAILED — {err}"),
    }

    let grok_result = mux_hook_installer::uninstall_grok_hook();
    match &grok_result {
        Ok(result) => {
            if result.config_removed {
                println!("grok:  removed {}", result.config_path.display());
            }
            if result.hook_removed {
                println!("grok:  removed {}", result.hook_path.display());
            }
            if !result.config_removed && !result.hook_removed {
                if result.hook_path.is_file() {
                    println!(
                        "grok:  {} exists but is not par-term's (left untouched)",
                        result.hook_path.display()
                    );
                } else {
                    println!("grok:  not installed");
                }
            }
        }
        Err(err) => println!("grok:  FAILED — {err}"),
    }

    println!();
    println!("Done.");
    Ok(())
}

fn dir_display(dir: std::io::Result<std::path::PathBuf>) -> String {
    match dir {
        Ok(path) => path.display().to_string(),
        Err(err) => format!("<unresolved: {err}>"),
    }
}

fn report_install(agent: &str, result: &std::io::Result<std::path::PathBuf>) {
    match result {
        Ok(path) => println!("{agent}: installed at {}", path.display()),
        Err(err) => println!("{agent}: FAILED — {err}"),
    }
}

fn report_removal(
    agent: &str,
    result: &std::io::Result<crate::mux_extension_installer::ExtensionRemoval>,
) {
    match result {
        Ok(removal) if removal.removed => {
            println!("{agent}: removed {}", removal.path.display());
        }
        Ok(removal) if removal.path.is_file() => println!(
            "{agent}: {} exists but is not par-term's (left untouched)",
            removal.path.display()
        ),
        Ok(_) => println!("{agent}: not installed"),
        Err(err) => println!("{agent}: FAILED — {err}"),
    }
}