From 11301a1126e09b45e39770576db6577de23c0afa Mon Sep 17 00:00:00 2001 From: steven-omaha <35634100+steven-omaha@users.noreply.github.com> Date: Mon, 27 Feb 2023 16:13:04 +0100 Subject: [PATCH] show supported backends in 'pacdef version' --- crates/pacdef_core/src/core.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/pacdef_core/src/core.rs b/crates/pacdef_core/src/core.rs index 204f81c..74b3139 100644 --- a/crates/pacdef_core/src/core.rs +++ b/crates/pacdef_core/src/core.rs @@ -404,8 +404,16 @@ fn show_error(error: &anyhow::Error, backend: &dyn Backend) { /// If the crate was compiled from git, return `pacdef, ()`. /// Otherwise return `pacdef, `. -const fn get_name_and_version() -> &'static str { - formatcp!("pacdef, version: {}", get_version_string()) +fn get_name_and_version() -> String { + let backends = get_included_backends(); + let mut result = format!("pacdef, version: {}\n", get_version_string()); + result.push_str("supported backends:"); + for b in backends { + result.push_str("\n "); + result.push_str(b); + } + + result } /// If the crate was compiled from git, return ` ()`. Otherwise @@ -420,3 +428,12 @@ pub const fn get_version_string() -> &'static str { formatcp!("{VERSION} ({HASH})") } } + +fn get_included_backends() -> Vec<&'static str> { + let mut result = vec![]; + for backend in Backends::iter() { + result.push(backend.get_section()) + } + result.sort_unstable(); + result +}