-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate_from_csv.rs
68 lines (64 loc) · 2.82 KB
/
generate_from_csv.rs
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
68
// 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 © 2024 LibMake. All rights reserved.
//! # Example: Generating Templates from a CSV File
//!
//! This is a simple test that demonstrates how to generate files from a CSV file
//! using the `generate_from_csv` function. It attempts to generate template files
//! from a CSV file and expects the operation to be successful.
//!
//! ## Usage
//!
//! To run this example, make sure you have a valid CSV file at the specified path.
//! The example will attempt to generate template files based on the CSV data.
//! If generation fails, it will print an error message.
//!
//! ```rust
//! // Import the necessary function for generating templates from a CSV file.
//! use libmake::generator::generate_from_csv;
//!
//! /// This is a simple test for generating files from a CSV file using the `generate_from_csv` function.
//! /// It attempts to generate template files from a CSV file and expects the operation to be successful.
//! // Define the path to the CSV file to be used for testing.
//! let csv_file_path = "./tests/data/mylibrary.csv";
//!
//! // Attempt to generate template files from the specified CSV file.
//! // If successful, it indicates that the generation process worked as expected.
//! generate_from_csv(csv_file_path)
//! .expect("Failed to generate the template files");
//! ```
// Import the necessary function for generating templates from a CSV file.
use libmake::generator::generate_from_csv;
/// Attempts to generate template files from the specified CSV file.
///
/// # Parameters
///
/// * `csv_file_path` - The path to the CSV file that contains the template generation information.
///
/// # Returns
///
/// * `Result<()>` - Returns `Ok(())` if the template generation process was successful, or returns an error if it failed.
///
/// # Examples
///
/// The following example demonstrates how to use the `generate_from_csv` function:
///
/// ```rust
/// use libmake::generator::generate_from_csv;
///
/// let csv_file_path = "./tests/data/mylibrary.csv";
///
/// // Attempt to generate template files from the specified CSV file.
/// // If successful, it indicates that the generation process worked as expected.
/// generate_from_csv(csv_file_path)
/// .expect("Failed to generate the template files");
/// ```
pub(crate) fn main() {
// Define the path to the CSV file to be used for testing.
let csv_file_path = "./tests/data/mylibrary.csv";
// Attempt to generate template files from the specified CSV file.
// If successful, it indicates that the generation process worked as expected.
generate_from_csv(csv_file_path)
.expect("Failed to generate the template files");
}