aboutsummaryrefslogtreecommitdiff
path: root/mingling_ci/src/cmd/cmd_show_manifests.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-18 08:27:36 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-18 08:27:36 +0800
commit5d0918ff5e19ebc67e4698bc308f6562779b7110 (patch)
treea9d7f5fb54afd16056b0a4c24d118db2d95f8d78 /mingling_ci/src/cmd/cmd_show_manifests.rs
parent00cf68abdd2be1cfca8b5a268d087ea2ccedf1dd (diff)
feat: add new Mingling CI system crate (WIP)
Add `mingling_ci` as a standalone CI system built on Mingling 0.4.0 to validate the next version, with report collection and manifest listing commands.
Diffstat (limited to 'mingling_ci/src/cmd/cmd_show_manifests.rs')
-rw-r--r--mingling_ci/src/cmd/cmd_show_manifests.rs71
1 files changed, 71 insertions, 0 deletions
diff --git a/mingling_ci/src/cmd/cmd_show_manifests.rs b/mingling_ci/src/cmd/cmd_show_manifests.rs
new file mode 100644
index 0000000..32e49c0
--- /dev/null
+++ b/mingling_ci/src/cmd/cmd_show_manifests.rs
@@ -0,0 +1,71 @@
+use std::path::PathBuf;
+
+use mingling::{
+ Grouped,
+ macros::{buffer, command, r_println, renderer},
+};
+
+use prettytable::{
+ Cell, Row, Table,
+ format::{FormatBuilder, LinePosition, LineSeparator},
+};
+
+use crate::res::{Manifests, package_name};
+
+#[command(node = "show-manifests")]
+pub fn show_manifests(manifests: &Manifests) -> ResultPrintManifests {
+ let mut entries: Vec<ManifestEntry> = manifests
+ .path
+ .iter()
+ .map(|path| ManifestEntry {
+ name: package_name(path),
+ path: path.clone(),
+ })
+ .collect();
+ entries.sort_by(|a, b| a.path.cmp(&b.path));
+ ResultPrintManifests { entries }
+}
+
+/// All manifests the CI will check, sorted by path.
+#[derive(Grouped)]
+pub struct ResultPrintManifests {
+ pub entries: Vec<ManifestEntry>,
+}
+
+#[derive(Debug, Clone)]
+pub struct ManifestEntry {
+ pub name: String,
+ pub path: PathBuf,
+}
+
+#[renderer(buffer)]
+pub fn render_print_manifests(r: ResultPrintManifests) {
+ let mut table = Table::new();
+
+ table.set_format(
+ FormatBuilder::new()
+ .column_separator('│')
+ .borders('│')
+ .separator(LinePosition::Top, LineSeparator::new('─', '┬', '┌', '┐'))
+ .separator(LinePosition::Title, LineSeparator::new('─', '┼', '├', '┤'))
+ .separator(LinePosition::Bottom, LineSeparator::new('─', '┴', '└', '┘'))
+ .padding(1, 1)
+ .build(),
+ );
+
+ table.set_titles(Row::new(vec![
+ Cell::new("#"),
+ Cell::new("Package-Name"),
+ Cell::new("Package-Path"),
+ ]));
+
+ for (index, entry) in r.entries.iter().enumerate() {
+ table.add_row(Row::new(vec![
+ Cell::new(&(index + 1).to_string()),
+ Cell::new(&entry.name),
+ Cell::new(&entry.path.to_string_lossy()),
+ ]));
+ }
+
+ r_println!("{table}");
+}