Implement CLI configuration and runtime management

This commit is contained in:
thakares committed 2026-05-13 15:54:15 +05:30
1 parent 2ac0afa691
commit 3edea4bdff
14 files changed
+1362 -53

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
use crate::cli::OutputFormat;
use serde::Serialize;
pub fn print<T>(format: OutputFormat, value: &T) -> Result<(), Box<dyn std::error::Error>>
where
T: Serialize + TextOutput,
{
match format {
OutputFormat::Text => println!("{}", value.to_text()),
OutputFormat::Json => println!("{}", serde_json::to_string_pretty(value)?),
OutputFormat::Yaml => print!("{}", serde_yaml::to_string(value)?),
}
Ok(())
}
pub trait TextOutput {
fn to_text(&self) -> String;
}