show supported backends in 'pacdef version'

This commit is contained in:
steven-omaha
2023-02-27 16:13:04 +01:00
parent 0affcff900
commit 11301a1126
+19 -2
View File
@@ -404,8 +404,16 @@ fn show_error(error: &anyhow::Error, backend: &dyn Backend) {
/// If the crate was compiled from git, return `pacdef, <version> (<hash>)`.
/// Otherwise return `pacdef, <version>`.
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 `<version> (<hash>)`. 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
}