nestrs-cli-rs 0.1.0

Rust port of the Nest CLI for the nestrs organization.
Documentation
//! Upstream source: `../nest-cli/lib/compiler/plugins/plugin-metadata-printer.ts`.

use std::path::PathBuf;

use serde_json::Value;

#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct PluginMetadataPrintOptions {
    pub output_path: PathBuf,
    pub metadata: Value,
}

#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct PluginMetadataPrinter;

impl PluginMetadataPrinter {
    pub fn render(options: &PluginMetadataPrintOptions) -> String {
        format!(
            "export default {};",
            serde_json::to_string_pretty(&options.metadata).unwrap_or_else(|_| "null".to_string())
        )
    }
}