gvc 0.1.1

CLI manager for Gradle version catalogs—check, list, update, and add dependencies with automatic version aliases
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
use crate::agents::catalog_editor::{parse_library_coordinate, parse_plugin_coordinate};
use crate::agents::{
    AddResult, AddTargetKind, CatalogEditor, DependencyUpdater, ProjectScannerAgent, UpdateReport,
    VersionControlAgent,
};
use crate::error::{GvcError, Result};
use crate::gradle::{GradleConfigParser, Repository};
use crate::maven::{MavenRepository, PluginPortalClient, VersionComparator};
use colored::Colorize;
use std::path::Path;

/// Add a new dependency or plugin entry to the version catalog
pub fn execute_add<P: AsRef<Path>>(
    project_path: P,
    plugin_flag: bool,
    _library_flag: bool,
    coordinate: &str,
    alias_override: Option<&str>,
    version_alias_override: Option<&str>,
    stable_only: bool,
) -> Result<()> {
    let project_path = project_path.as_ref();
    println!(
        "{}",
        "Adding entry to Gradle version catalog...".cyan().bold()
    );

    println!("\n{}", "1. Validating project structure...".yellow());
    let scanner = ProjectScannerAgent::new(project_path);
    let project_info = scanner.validate()?;
    println!("{}", "✓ Project structure is valid".green());

    let (target, coordinate) = resolve_add_target(plugin_flag, coordinate)?;

    println!(
        "\n{}",
        "2. Reading Gradle repository configuration...".yellow()
    );
    let gradle_parser = GradleConfigParser::new(project_path);
    let gradle_config = gradle_parser.parse()?;
    println!(
        "   Found {} repositories:",
        gradle_config.repositories.len()
    );
    for repo in &gradle_config.repositories {
        println!("{} ({})", repo.name.bright_cyan(), repo.url.dimmed());
    }

    println!(
        "\n{}",
        "3. Validating coordinate against remote repositories...".yellow()
    );

    let repositories = gradle_config.repositories.clone();

    let resolved_coordinate = match target {
        AddTargetKind::Library => {
            let (group, artifact, version) = parse_library_coordinate(coordinate)?;
            let resolved_version = resolve_version_for_library(
                &repositories,
                &group,
                &artifact,
                version,
                stable_only,
            )?;
            format!("{}:{}:{}", group, artifact, resolved_version)
        }
        AddTargetKind::Plugin => {
            let (plugin_id, version) = parse_plugin_coordinate(coordinate)?;
            let resolved_version = resolve_version_for_plugin(&plugin_id, version, stable_only)?;
            format!("{}:{}", plugin_id, resolved_version)
        }
    };

    println!("\n{}", "4. Writing to version catalog...".yellow());
    let editor = CatalogEditor::new(&project_info.toml_path);

    let result = match target {
        AddTargetKind::Library => {
            editor.add_library(&resolved_coordinate, alias_override, version_alias_override)
        }
        AddTargetKind::Plugin => {
            editor.add_plugin(&resolved_coordinate, alias_override, version_alias_override)
        }
    }?;

    print_add_result(&result);

    println!("\n{}", "✨ Entry added successfully!".green().bold());

    Ok(())
}

fn resolve_add_target(plugin_flag: bool, coordinate: &str) -> Result<(AddTargetKind, &str)> {
    if coordinate.trim().is_empty() {
        return Err(GvcError::ProjectValidation(
            "Coordinate is required. Example: gvc add group:artifact:version".into(),
        ));
    }

    let target = if plugin_flag {
        AddTargetKind::Plugin
    } else {
        AddTargetKind::Library
    };

    Ok((target, coordinate))
}

fn print_add_result(result: &AddResult) {
    match result.target {
        AddTargetKind::Library => {
            println!(
                "{}",
                format!(
                    "✓ Library '{}' added with version alias '{}'",
                    result.alias, result.version_alias
                )
                .green()
            );
        }
        AddTargetKind::Plugin => {
            println!(
                "{}",
                format!(
                    "✓ Plugin '{}' added with version alias '{}'",
                    result.alias, result.version_alias
                )
                .green()
            );
        }
    }
}

fn resolve_version_for_library(
    repositories: &[Repository],
    group: &str,
    artifact: &str,
    version: String,
    stable_only: bool,
) -> Result<String> {
    let repo = MavenRepository::with_repositories(repositories.to_vec())?;
    let available_versions = repo.fetch_available_versions(group, artifact)?;

    if available_versions.is_empty() {
        return Err(GvcError::ProjectValidation(format!(
            "No versions found for '{}:{}' in the configured repositories",
            group, artifact
        )));
    }

    let target_version = if version.eq_ignore_ascii_case("latest") {
        match VersionComparator::get_latest(&available_versions, stable_only) {
            Some(v) => v,
            None => {
                if stable_only {
                    return Err(GvcError::ProjectValidation(format!(
                        "No stable versions available for '{}:{}'. Re-run with --no-stable-only to allow pre-releases.",
                        group, artifact
                    )));
                }
                return Err(GvcError::ProjectValidation(format!(
                    "No versions available for '{}:{}'",
                    group, artifact
                )));
            }
        }
    } else if available_versions.iter().any(|v| v == &version) {
        version
    } else {
        return Err(GvcError::ProjectValidation(format!(
            "Version '{}' for '{}:{}' not found in configured repositories",
            version, group, artifact
        )));
    };

    println!(
        "   {}",
        format!("{group}:{artifact} @ {target_version}").green()
    );

    Ok(target_version)
}

fn resolve_version_for_plugin(
    plugin_id: &str,
    version: String,
    stable_only: bool,
) -> Result<String> {
    let client = PluginPortalClient::new()?;
    let available_versions = client.fetch_available_plugin_versions(plugin_id)?;

    if available_versions.is_empty() {
        return Err(GvcError::ProjectValidation(format!(
            "No versions found for plugin '{}' on Gradle Plugin Portal",
            plugin_id
        )));
    }

    let target_version = if version.eq_ignore_ascii_case("latest") {
        match VersionComparator::get_latest(&available_versions, stable_only) {
            Some(v) => v,
            None => {
                if stable_only {
                    return Err(GvcError::ProjectValidation(format!(
                        "No stable versions available for plugin '{}'. Re-run with --no-stable-only to include pre-releases.",
                        plugin_id
                    )));
                }
                return Err(GvcError::ProjectValidation(format!(
                    "No versions available for plugin '{}'",
                    plugin_id
                )));
            }
        }
    } else if available_versions.iter().any(|v| v == &version) {
        version
    } else {
        return Err(GvcError::ProjectValidation(format!(
            "Version '{}' for plugin '{}' not found on Gradle Plugin Portal",
            version, plugin_id
        )));
    };

    println!(
        "   {}",
        format!("✓ plugin {plugin_id} @ {target_version}").green()
    );

    Ok(target_version)
}

/// Execute the update workflow
pub fn execute_update<P: AsRef<Path>>(
    project_path: P,
    interactive: bool,
    filter: Option<String>,
    stable_only: bool,
    no_git: bool,
) -> Result<()> {
    let project_path = project_path.as_ref();
    println!("{}", "Starting dependency update process...".cyan().bold());

    // Step 1: Validate project structure
    println!("\n{}", "1. Validating project structure...".yellow());
    let scanner = ProjectScannerAgent::new(project_path);
    let project_info = scanner.validate()?;
    println!("{}", "✓ Project structure is valid".green());

    // Step 2: Check Git status (if Git is available and not disabled)
    if project_info.has_git && !no_git {
        println!("\n{}", "2. Checking Git status...".yellow());
        let git_agent = VersionControlAgent::new(project_path);

        if !git_agent.is_working_directory_clean()? {
            println!(
                "{}",
                "⚠ Warning: Working directory has uncommitted changes".red()
            );
            println!("Please commit or stash your changes before proceeding.");
            return Ok(());
        }
        println!("{}", "✓ Working directory is clean".green());
    } else if !no_git {
        println!(
            "\n{}",
            "2. Git repository not detected, skipping Git checks".yellow()
        );
    }

    // Step 3: Read Gradle repository configuration
    println!(
        "\n{}",
        "3. Reading Gradle repository configuration...".yellow()
    );
    let gradle_parser = GradleConfigParser::new(project_path);
    let gradle_config = gradle_parser.parse()?;

    println!(
        "   Found {} repositories:",
        gradle_config.repositories.len()
    );
    for repo in &gradle_config.repositories {
        println!("{} ({})", repo.name.bright_cyan(), repo.url.dimmed());
    }

    // Step 4: Update dependencies
    println!("\n{}", "4. Updating dependencies...".yellow());
    let updater = DependencyUpdater::with_repositories(gradle_config.repositories)?;

    let report = match filter {
        Some(pattern) => match updater.update_targeted_dependency(
            &project_info.toml_path,
            stable_only,
            interactive,
            &pattern,
        ) {
            Ok(report) => report,
            Err(GvcError::UserCancelled) => {
                println!("\n{}", "Update cancelled by user.".yellow());
                return Ok(());
            }
            Err(e) => return Err(e),
        },
        None => {
            match updater.update_version_catalog(&project_info.toml_path, stable_only, interactive)
            {
                Ok(report) => report,
                Err(GvcError::UserCancelled) => {
                    println!("\n{}", "Update cancelled by user.".yellow());
                    return Ok(());
                }
                Err(e) => return Err(e),
            }
        }
    };

    println!("{}", "✓ Update completed".green());

    // Step 5: Display summary
    print_update_report(&report);

    // Step 6: Git operations (if enabled)
    if project_info.has_git && !no_git && !report.is_empty() {
        println!("\n{}", "5. Creating Git commit...".yellow());
        let git_agent = VersionControlAgent::new(project_path);
        let branch_name = git_agent.commit_to_new_branch()?;
        println!(
            "{}",
            format!("✓ Changes committed to branch: {}", branch_name).green()
        );
    } else if report.is_empty() {
        println!("\n{}", "No updates were applied".yellow());
    }

    println!(
        "\n{}",
        "✨ Update process completed successfully!".green().bold()
    );
    Ok(())
}

/// Execute the check workflow (dry-run)
pub fn execute_check<P: AsRef<Path>>(project_path: P, stable_only: bool) -> Result<()> {
    let project_path = project_path.as_ref();
    let version_channel = if stable_only { "stable" } else { "all" };
    println!(
        "{}",
        format!(
            "Checking for available updates ({} versions)...",
            version_channel
        )
        .cyan()
        .bold()
    );

    // Step 1: Validate project structure
    println!("\n{}", "1. Validating project structure...".yellow());
    let scanner = ProjectScannerAgent::new(project_path);
    let project_info = scanner.validate()?;
    println!("{}", "✓ Project structure is valid".green());

    // Step 2: Read Gradle repository configuration
    println!(
        "\n{}",
        "2. Reading Gradle repository configuration...".yellow()
    );
    let gradle_parser = GradleConfigParser::new(project_path);
    let gradle_config = gradle_parser.parse()?;

    println!(
        "   Found {} repositories:",
        gradle_config.repositories.len()
    );
    for repo in &gradle_config.repositories {
        println!("{} ({})", repo.name.bright_cyan(), repo.url.dimmed());
    }

    // Step 3: Check for updates without modifying the file
    println!("\n{}", "3. Checking for available updates...".yellow());

    let updater = DependencyUpdater::with_repositories(gradle_config.repositories)?;

    // 读取当前的TOML但不写回
    let report = updater.check_for_updates(&project_info.toml_path, stable_only)?;

    println!("{}", "✓ Check completed".green());

    // Step 4: Display available updates
    print_available_updates(&report, stable_only);

    Ok(())
}

fn print_available_updates(report: &UpdateReport, stable_only: bool) {
    if report.is_empty() {
        println!("\n{}", "✨ All dependencies are up to date!".green().bold());
        return;
    }

    println!("\n{}", "📦 Available Updates:".cyan().bold());
    println!(
        "{}",
        format!("Found {} update(s)", report.total_updates()).yellow()
    );

    if stable_only {
        println!("{}", "   (showing stable versions only)".dimmed());
    } else {
        println!(
            "{}",
            "   (showing all versions including pre-releases)".dimmed()
        );
    }

    if !report.version_updates.is_empty() {
        println!("\n{}:", "Version updates".cyan().bold());
        for (name, (old, new)) in &report.version_updates {
            println!(
                "{} {}{}",
                name.white().bold(),
                old.red(),
                new.green().bold()
            );
        }
    }

    if !report.library_updates.is_empty() {
        println!("\n{}:", "Library updates".cyan().bold());
        for (name, (old, new)) in &report.library_updates {
            let stability = if is_stable_version(new) {
                "stable".green()
            } else {
                "pre-release".yellow()
            };
            println!(
                "{} {}{} ({})",
                name.white().bold(),
                old.dimmed(),
                new.green().bold(),
                stability
            );
        }
    }

    if !report.plugin_updates.is_empty() {
        println!("\n{}:", "Plugin updates".cyan().bold());
        for (name, (old, new)) in &report.plugin_updates {
            println!(
                "{} {}{}",
                name.white().bold(),
                old.red(),
                new.green().bold()
            );
        }
    }

    println!("\n{}", "To apply these updates, run:".dimmed());
    if stable_only {
        println!("  {}", "gvc update --stable-only".cyan());
    } else {
        println!("  {}", "gvc update".cyan());
    }
}

fn is_stable_version(version: &str) -> bool {
    let lower = version.to_lowercase();
    !lower.contains("alpha")
        && !lower.contains("beta")
        && !lower.contains("rc")
        && !lower.contains("snapshot")
        && !lower.contains("dev")
}

/// Execute the list workflow - display all dependencies
pub fn execute_list<P: AsRef<Path>>(project_path: P) -> Result<()> {
    let project_path = project_path.as_ref();
    println!(
        "{}",
        "Listing dependencies in version catalog...".cyan().bold()
    );

    // Step 1: Validate project structure
    println!("\n{}", "1. Validating project structure...".yellow());
    let scanner = ProjectScannerAgent::new(project_path);
    let project_info = scanner.validate()?;
    println!("{}", "✓ Project structure is valid".green());

    // Step 2: Parse TOML file
    println!("\n{}", "2. Reading version catalog...".yellow());
    let content = std::fs::read_to_string(&project_info.toml_path).map_err(|e| {
        crate::error::GvcError::TomlParsing(format!("Failed to read catalog: {}", e))
    })?;

    let doc = content
        .parse::<toml_edit::DocumentMut>()
        .map_err(|e| crate::error::GvcError::TomlParsing(format!("Failed to parse TOML: {}", e)))?;

    println!("{}", "✓ Catalog loaded".green());

    // Step 3: Display dependencies
    print_dependencies(&doc);

    Ok(())
}

fn print_dependencies(doc: &toml_edit::DocumentMut) {
    use crate::maven::parse_maven_coordinate;
    use std::collections::HashMap;

    println!("\n{}", "📦 Dependencies:".cyan().bold());

    // First, collect all version references
    let mut version_refs = HashMap::new();
    if let Some(versions) = doc.get("versions").and_then(|v| v.as_table()) {
        for (name, value) in versions.iter() {
            if let Some(version_str) = value.as_str() {
                version_refs.insert(name.to_string(), version_str.to_string());
            }
        }
    }

    // Display [libraries] section in Maven coordinate format
    if let Some(libraries) = doc.get("libraries").and_then(|v| v.as_table()) {
        if !libraries.is_empty() {
            println!("\n{}", "Libraries:".yellow().bold());
            let mut lib_list: Vec<_> = libraries.iter().collect();
            lib_list.sort_by_key(|(k, _)| *k);

            for (name, value) in lib_list {
                let mut coordinate = String::new();
                let mut version_str = String::new();

                // Parse the library specification
                if let Some(str_value) = value.as_str() {
                    // Format 1: "group:artifact:version"
                    if let Some((group, artifact, version)) = parse_maven_coordinate(str_value) {
                        coordinate = format!("{}:{}", group, artifact);
                        if let Some(v) = version {
                            version_str = v.to_string();
                        }
                    }
                } else if let Some(inline_table) = value.as_inline_table() {
                    // Inline table format: { group = "...", name = "...", version.ref = "..." }
                    if let Some(module) = inline_table.get("module").and_then(|v| v.as_str()) {
                        if let Some((group, artifact, _)) = parse_maven_coordinate(module) {
                            coordinate = format!("{}:{}", group, artifact);
                        }
                    } else if let Some(group) = inline_table.get("group").and_then(|v| v.as_str()) {
                        if let Some(artifact) = inline_table.get("name").and_then(|v| v.as_str()) {
                            coordinate = format!("{}:{}", group, artifact);
                        }
                    }

                    // Get version
                    if let Some(version) = inline_table.get("version") {
                        if let Some(v) = version.as_str() {
                            version_str = v.to_string();
                        } else if let Some(version_ref) = version.as_inline_table() {
                            if let Some(ref_name) = version_ref.get("ref").and_then(|v| v.as_str())
                            {
                                if let Some(resolved) = version_refs.get(ref_name) {
                                    version_str = resolved.clone();
                                } else {
                                    version_str = format!("${{{}}}", ref_name);
                                }
                            }
                        }
                    }
                } else if let Some(table) = value.as_table() {
                    // Regular table format
                    if let Some(module) = table.get("module").and_then(|v| v.as_str()) {
                        if let Some((group, artifact, _)) = parse_maven_coordinate(module) {
                            coordinate = format!("{}:{}", group, artifact);
                        }
                    } else if let Some(group) = table.get("group").and_then(|v| v.as_str()) {
                        if let Some(artifact) = table.get("name").and_then(|v| v.as_str()) {
                            coordinate = format!("{}:{}", group, artifact);
                        }
                    }

                    // Get version
                    if let Some(version) = table.get("version") {
                        if let Some(v) = version.as_str() {
                            version_str = v.to_string();
                        } else if let Some(version_ref) = version.as_table() {
                            if let Some(ref_name) = version_ref.get("ref").and_then(|v| v.as_str())
                            {
                                if let Some(resolved) = version_refs.get(ref_name) {
                                    version_str = resolved.clone();
                                } else {
                                    version_str = format!("${{{}}}", ref_name);
                                }
                            }
                        } else if let Some(version_ref) = version.as_inline_table() {
                            if let Some(ref_name) = version_ref.get("ref").and_then(|v| v.as_str())
                            {
                                if let Some(resolved) = version_refs.get(ref_name) {
                                    version_str = resolved.clone();
                                } else {
                                    version_str = format!("${{{}}}", ref_name);
                                }
                            }
                        }
                    }
                }

                if !coordinate.is_empty() && !version_str.is_empty() {
                    println!("  {}", format!("{}:{}", coordinate, version_str).cyan());
                } else if !coordinate.is_empty() {
                    println!("  {} {}", coordinate.cyan(), "(version unknown)".dimmed());
                } else {
                    println!("  {} {}", name.yellow(), "(coordinate unknown)".dimmed());
                }
            }
        }
    }

    // Display [plugins] section
    if let Some(plugins) = doc.get("plugins").and_then(|v| v.as_table()) {
        if !plugins.is_empty() {
            println!("\n{}", "Plugins:".yellow().bold());
            let mut plugin_list: Vec<_> = plugins.iter().collect();
            plugin_list.sort_by_key(|(k, _)| *k);

            for (name, value) in plugin_list {
                let mut plugin_id = String::new();
                let mut version_str = String::new();

                if let Some(str_value) = value.as_str() {
                    plugin_id = name.to_string();
                    version_str = str_value.to_string();
                } else if let Some(table) = value.as_table() {
                    if let Some(id) = table.get("id").and_then(|v| v.as_str()) {
                        plugin_id = id.to_string();
                    } else {
                        plugin_id = name.to_string();
                    }

                    if let Some(version) = table.get("version") {
                        if let Some(v) = version.as_str() {
                            version_str = v.to_string();
                        } else if let Some(version_ref) = version.as_table() {
                            if let Some(ref_name) = version_ref.get("ref").and_then(|v| v.as_str())
                            {
                                // Resolve version reference
                                if let Some(resolved) = version_refs.get(ref_name) {
                                    version_str = resolved.clone();
                                } else {
                                    version_str = format!("${{{}}}", ref_name);
                                }
                            }
                        }
                    }
                }

                if !version_str.is_empty() {
                    println!("  {}", format!("{}:{}", plugin_id, version_str).magenta());
                } else {
                    println!("  {} {}", plugin_id.magenta(), "(version unknown)".dimmed());
                }
            }
        }
    }

    // Summary
    let library_count = doc
        .get("libraries")
        .and_then(|v| v.as_table())
        .map(|t| t.len())
        .unwrap_or(0);
    let plugin_count = doc
        .get("plugins")
        .and_then(|v| v.as_table())
        .map(|t| t.len())
        .unwrap_or(0);

    println!("\n{}", "Summary:".cyan().bold());
    println!("  {} libraries", library_count.to_string().yellow());
    println!("  {} plugins", plugin_count.to_string().yellow());
}

fn print_update_report(report: &UpdateReport) {
    if report.is_empty() {
        println!("\n{}", "No updates were found".yellow());
        return;
    }

    println!("\n{}", "Update Summary:".cyan().bold());
    println!(
        "{}",
        format!("Total updates: {}", report.total_updates()).green()
    );

    if !report.version_updates.is_empty() {
        println!("\n{}:", "Version updates".cyan());
        for (name, (old, new)) in &report.version_updates {
            println!(
                "{} {}{}",
                name.white().bold(),
                old.red(),
                new.green()
            );
        }
    }

    if !report.library_updates.is_empty() {
        println!("\n{}:", "Library updates".cyan());
        for (name, (old, new)) in &report.library_updates {
            println!(
                "{} {}{}",
                name.white().bold(),
                old.red(),
                new.green()
            );
        }
    }

    if !report.plugin_updates.is_empty() {
        println!("\n{}:", "Plugin updates".cyan());
        for (name, (old, new)) in &report.plugin_updates {
            println!(
                "{} {}{}",
                name.white().bold(),
                old.red(),
                new.green()
            );
        }
    }
}