1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright notice and licensing information.
// These lines indicate the copyright of the software and its licensing terms.
// SPDX-License-Identifier: Apache-2.0 OR MIT indicates dual licensing under Apache 2.0 or MIT licenses.
// Copyright © 2023-2024 LibMake. All rights reserved.
//! # Example: Generating Templates from a Configuration File
//!
//! This is an example that demonstrates how to generate template files
//! based on a configuration file using the `generate_from_config` function.
//!
//! ## Usage
//!
//! To run this example, make sure you have a valid configuration file at the specified path.
//! The example allows you to define the file type (e.g., "yaml") and the file path.
//! It then calls the `generate_from_config` function with the file path and file type as parameters.
//!
//! If generation is successful, it does nothing (the template files are created).
//! If there is an error during generation, it prints an error message.
//!
//! ```rust
//! use libmake::generator::generate_from_config;
//!
//! // Define the file path for the configuration file.
//! let file_path = "./tests/data/mylibrary.yaml";
//!
//! // Define the file type, which is "yaml" in this case.
//! let file_type = "yaml";
//!
//! // Call the generate_from_config function with the file_path and file_type.
//! // This function generates template files based on the configuration.
//! match generate_from_config(file_path, file_type) {
//! // If generation is successful, do nothing (the template files are created).
//! Ok(_) => (),
//! // If there is an error during generation, print an error message.
//! Err(err) => eprintln!("Error: {}", err),
//! }
//! ```
use generate_from_config;
/// Generate template files based on a configuration file.
///
/// # Arguments
///
/// * `file_path` - Path to the configuration file.
/// * `file_type` - Type of the configuration file (e.g., "yaml").
///
/// # Returns
///
/// * `Ok(())` - If generation is successful.
/// * `Err(String)` - If there is an error during generation.
pub