kmmp-project-manager 0.1.0

kmmp-project-manager is a Rust crate for Kotlin Multiplatform (KMP) projects, offering a lightweight alternative to Android Studio. It provides tools for project creation, structure management, build automation, code generation, IDE integration, dependency management, and project configuration.
Documentation
#[cfg(feature = "generate")]
use std::{
    fs::File,
    io::Write
};

/// Represents the contents of the Gradle properties file.

#[derive(Debug, PartialEq, PartialOrd)]
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(bound(deserialize = "'de: 'a"))]
pub struct GradleProperties<'a>(Vec<(&'a str, &'a str)>);

impl GradleProperties<'_> {
    /// Name of generated file name for struct
    pub const FILE_NAME : &str = "gradle.properties";
}

impl<'a> From<Vec<(&'a str, &'a str)>> for GradleProperties<'a> {
    /// Creates a new `GradleProperties` instance with the specified properties.
    ///
    /// # Arguments
    ///
    /// * `properties` - A reference to the `HashMap` containing the properties.
    ///
    /// # Example
    ///
    /// ```
    /// use std::collections::HashMap;
    /// use kmmp_structure::gradle::GradleProperties;
    ///
    /// let properties: HashMap<&str, &str> = [("key1", "value1"), ("key2", "value2")].iter().cloned().collect();
    /// let gradle_properties = GradleProperties::new(&properties);
    /// ```
    fn from(vector : Vec<(&'a str, &'a str)>) -> Self {
        Self(vector)
    }
}

impl std::fmt::Display for GradleProperties<'_> {
    /// Formats the `GradleProperties` as a string.
    ///
    /// # Example
    ///
    /// ```
    /// use std::collections::HashMap;
    /// use kmmp_structure::gradle::GradleProperties;
    ///
    /// let properties: HashMap<&str, &str> = [("key1", "value1"), ("key2", "value2")].iter().cloned().collect();
    /// let gradle_properties = GradleProperties::new(&properties);
    ///
    /// assert_eq!(gradle_properties.to_string(), "/* formatted properties */");
    /// ```
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 
        for (key, value) in &self.0 {
            writeln!(f, "{}={}", key, value)?;
        };
        Ok(())
    }
}

#[cfg(feature = "generate")]
impl crate::Generate for GradleProperties<'_> {
    fn generate(&self,directory : &str) {
        let create_directory = format!("{}\\{}",directory,Self::FILE_NAME);
        let _ = File::create(&create_directory).expect("Error Creating File").write_all(self.to_string().as_bytes());
    }
}