Skip to content

Commit 971552c

Browse files
feat(branch): feat/libmake
1 parent f74abd6 commit 971552c

36 files changed

+488
-40
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ build
66
Cargo.lock
77
Icon?
88
src/.DS_Store
9+
/my_library/

Cargo.toml

+11-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ license = "MIT OR Apache-2.0"
1414
name = "libmake"
1515
repository = "https://github.com/sebastienrousseau/libmake.git"
1616
rust-version = "1.69.0"
17-
version = "0.1.8"
17+
version = "0.1.9"
1818
include = [
1919
"/CONTRIBUTING.md",
2020
"/LICENSE-APACHE",
@@ -41,20 +41,19 @@ path = "benches/criterion.rs"
4141
debug = true
4242

4343
[dependencies]
44-
assert_cmd = "2.0.11"
45-
clap = "4.2.7"
46-
csv = "1.2.1"
44+
assert_cmd = "2.0.12"
45+
clap = "4.4.6"
46+
csv = "1.3.0"
4747
figlet-rs = "0.1.5"
48-
openssl = { version = "0.10.52", features = ["vendored"] }
49-
reqwest = { version = "0.11.17", features = ["blocking"] }
50-
serde = { version = "1.0.162", features = ["derive"] }
51-
serde_json = "1.0.96"
52-
serde_yaml = "0.9.21"
53-
toml = "0.7.3"
48+
reqwest = { version = "0.11.22", features = ["blocking"] }
49+
serde = { version = "1.0.188", features = ["derive"] }
50+
serde_json = "1.0.107"
51+
serde_yaml = "0.9.25"
52+
toml = "0.8.2"
5453

5554
[dev-dependencies]
56-
criterion = "0.5.0"
57-
predicates = "3.0.3"
55+
criterion = "0.5.1"
56+
predicates = "3.0.4"
5857

5958
[lib]
6059
crate-type = ["lib"]

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,6 @@ this project.
338338
[codecov-badge]: https://img.shields.io/codecov/c/github/sebastienrousseau/libmake?style=for-the-badge&token=Q9KJ6XXL67 'Codecov'
339339
[crates-badge]: https://img.shields.io/crates/v/libmake.svg?style=for-the-badge 'Crates.io Badge'
340340
[docs-badge]: https://img.shields.io/docsrs/libmake.svg?style=for-the-badge 'Docs.rs Badge'
341-
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.1.8-orange.svg?style=for-the-badge 'Lib.rs Badge'
341+
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.1.9-orange.svg?style=for-the-badge 'Lib.rs Badge'
342342
[license-badge]: https://img.shields.io/crates/l/libmake.svg?style=for-the-badge 'License Badge'
343343
[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust Badge'

TEMPLATE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
alt="LibMake logo" width="261" align="right" />
55

66
<!-- markdownlint-enable MD033 MD041 -->
7-
# LibMake v0.1.8 🦀
7+
# LibMake v0.1.9 🦀
88

99
A code generator to reduce repetitive tasks and build high-quality Rust libraries.
1010

@@ -63,6 +63,6 @@ The library is designed to be used as a command-line tool. It is available on [C
6363
[codecov-badge]: https://img.shields.io/codecov/c/github/sebastienrousseau/libmake?style=for-the-badge&token=Q9KJ6XXL67 'Codecov'
6464
[crates-badge]: https://img.shields.io/crates/v/libmake.svg?style=for-the-badge 'Crates.io Badge'
6565
[docs-badge]: https://img.shields.io/docsrs/libmake.svg?style=for-the-badge 'Docs.rs Badge'
66-
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.1.8-orange.svg?style=for-the-badge 'Lib.rs Badge'
66+
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.1.9-orange.svg?style=for-the-badge 'Lib.rs Badge'
6767
[license-badge]: https://img.shields.io/crates/l/libmake.svg?style=for-the-badge 'License Badge'
6868
[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust Badge'

benches/criterion.rs

+39
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
//! # Benchmark: libmake
2+
//!
3+
//! This benchmark tests the performance of the `libmake` crate using the Criterion library.
4+
//! It measures the execution time of the `run` function from the `libmake` crate.
5+
//!
6+
//! ## Purpose
7+
//!
8+
//! The purpose of this benchmark is to assess the execution time of the `run` function
9+
//! from the `libmake` crate under controlled conditions. It helps identify any potential
10+
//! performance bottlenecks and allows for optimization if needed.
11+
//!
12+
//! ## Usage
13+
//!
14+
//! To run this benchmark, ensure that you have the `criterion` and `libmake` crates
15+
//! included as dependencies in your project's `Cargo.toml` file.
16+
//!
17+
//! In your project's code, you can use the `criterion_group` and `criterion_main` macros
18+
//! to define and run benchmarks. In this specific benchmark, the `libmake_benchmark` function
19+
//! is defined to measure the execution time of the `run` function.
20+
//!
21+
//! ```rust
22+
//! extern crate criterion;
23+
//! extern crate libmake;
24+
//!
25+
//! use criterion::{criterion_group, criterion_main, Criterion};
26+
//! use libmake::run;
27+
//!
28+
//! fn libmake_benchmark(c: &mut Criterion) {
29+
//! c.bench_function("libmake", |b| b.iter(run));
30+
//! }
31+
//!
32+
//! criterion_group!(benches, libmake_benchmark);
33+
//! criterion_main!(benches);
34+
//! ```
35+
//!
36+
//! Running this benchmark will provide performance metrics for the `run` function
37+
//! from the `libmake` crate, helping you evaluate and optimize its performance.
38+
39+
#![allow(missing_docs)]
140
extern crate criterion;
241
extern crate libmake;
342

build.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
// Copyright © 2023 LibMake. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
//! This is the main function for the build script.
5+
//!
6+
//! Currently, it only instructs Cargo to re-run this build script if `build.rs` is changed.
17
fn main() {
28
// Avoid unnecessary re-building.
39
println!("cargo:rerun-if-changed=build.rs");
4-
}
10+
}

examples/generate_from_args.rs

+31
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,51 @@
1+
//! A simple test program for the `generate_from_args` function.
2+
//!
3+
//! This program simulates command line arguments and calls the `generate_from_args` function
4+
//! to generate files based on the provided arguments.
5+
//!
6+
//! # Arguments
7+
//!
8+
//! * `--author=<value>` - The author name for the generated files.
9+
//! * `--output=<value>` - The output directory for the generated files.
10+
//!
11+
//! # Example
12+
//!
13+
//! To run this test program, use the following command:
14+
//!
15+
//! ```
16+
//! $ cargo run --release
17+
//! ```
18+
//!
19+
//! Make sure to replace `<value>` with the desired values for `--author` and `--output`.
20+
//!
21+
//! If successful, this program will print "Successfully generated files!".
22+
//!
23+
//! If there is an error, it will print an error message.
24+
25+
// Import the necessary function for generating files from arguments
126
use libmake::generator::generate_from_args;
227

328
fn main() -> std::io::Result<()> {
29+
// Simulate command line arguments
430
let args = "--author=Me --output=my_library"
531
.split(' ')
632
.map(|s| s.to_string())
733
.collect::<Vec<String>>();
834

35+
// Check if there are at least two arguments (program name and at least one option)
936
if args.len() < 2 {
1037
eprintln!("Usage: {} <args>", args[0]);
1138
return Ok(());
1239
}
1340

41+
// Join the arguments (excluding the program name) into a single string
1442
let args_str = args[1..].join(" ");
43+
44+
// Call the `generate_from_args` function with the arguments string
1545
let result = generate_from_args(&args_str);
1646
println!("{:?}", result);
1747

48+
// Check the result of the function call and print a message accordingly
1849
match result {
1950
Ok(()) => println!("Successfully generated files!"),
2051
Err(err) => eprintln!("Error: {}", err),

examples/generate_from_config.rs

+45-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,51 @@
1+
//! # Example: Generating Templates from a Configuration File
2+
//!
3+
//! This is an example that demonstrates how to generate template files
4+
//! based on a configuration file using the `generate_from_config` function.
5+
//!
6+
//! ## Usage
7+
//!
8+
//! To run this example, make sure you have a valid configuration file at the specified path.
9+
//! The example allows you to define the file type (e.g., "yaml") and the file path.
10+
//! It then calls the `generate_from_config` function with the file path and file type as parameters.
11+
//!
12+
//! If generation is successful, it does nothing (the template files are created).
13+
//! If there is an error during generation, it prints an error message.
14+
//!
15+
//! ```rust
16+
//! use libmake::generator::generate_from_config;
17+
//!
18+
//! // Define the file path for the configuration file.
19+
//! let file_path = "./tests/data/mylibrary.yaml";
20+
//!
21+
//! // Define the file type, which is "yaml" in this case.
22+
//! let file_type = "yaml";
23+
//!
24+
//! // Call the generate_from_config function with the file_path and file_type.
25+
//! // This function generates template files based on the configuration.
26+
//! match generate_from_config(file_path, file_type) {
27+
//! // If generation is successful, do nothing (the template files are created).
28+
//! Ok(_) => (),
29+
//! // If there is an error during generation, print an error message.
30+
//! Err(err) => eprintln!("Error: {}", err),
31+
//! }
32+
//! ```
33+
134
use libmake::generator::generate_from_config;
35+
236
fn main() {
37+
// Define the file path for the configuration file.
338
let file_path = "./tests/data/mylibrary.yaml";
39+
40+
// Define the file type, which is "yaml" in this case.
441
let file_type = "yaml";
542

6-
generate_from_config(file_path, file_type)
7-
.expect("Failed to generate the template files");
43+
// Call the generate_from_config function with the file_path and file_type.
44+
// This function generates template files based on the configuration.
45+
match generate_from_config(file_path, file_type) {
46+
// If generation is successful, do nothing (the template files are created).
47+
Ok(_) => (),
48+
// If there is an error during generation, print an error message.
49+
Err(err) => eprintln!("Error: {}", err),
50+
}
851
}

examples/generate_from_csv.rs

+35
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
1+
//! # Example: Generating Templates from a CSV File
2+
//!
3+
//! This is a simple test that demonstrates how to generate files from a CSV file
4+
//! using the `generate_from_csv` function. It attempts to generate template files
5+
//! from a CSV file and expects the operation to be successful.
6+
//!
7+
//! ## Usage
8+
//!
9+
//! To run this example, make sure you have a valid CSV file at the specified path.
10+
//! The example will attempt to generate template files based on the CSV data.
11+
//! If generation fails, it will print an error message.
12+
//!
13+
//! ```rust
14+
//! // Import the necessary function for generating templates from a CSV file.
15+
//! use libmake::generator::generate_from_csv;
16+
//!
17+
//! /// This is a simple test for generating files from a CSV file using the `generate_from_csv` function.
18+
//! /// It attempts to generate template files from a CSV file and expects the operation to be successful.
19+
//! // Define the path to the CSV file to be used for testing.
20+
//! let csv_file_path = "./tests/data/mylibrary.csv";
21+
//!
22+
//! // Attempt to generate template files from the specified CSV file.
23+
//! // If successful, it indicates that the generation process worked as expected.
24+
//! generate_from_csv(csv_file_path)
25+
//! .expect("Failed to generate the template files");
26+
//! ```
27+
28+
// Import the necessary function for generating templates from a CSV file.
129
use libmake::generator::generate_from_csv;
30+
31+
/// This is a simple test for generating files from a CSV file using the `generate_from_csv` function.
32+
/// It attempts to generate template files from a CSV file and expects the operation to be successful.
233
fn main() {
34+
// Define the path to the CSV file to be used for testing.
335
let csv_file_path = "./tests/data/mylibrary.csv";
36+
37+
// Attempt to generate template files from the specified CSV file.
38+
// If successful, it indicates that the generation process worked as expected.
439
generate_from_csv(csv_file_path)
540
.expect("Failed to generate the template files");
641
}

examples/generate_from_json.rs

+38
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,44 @@
1+
//! # Example: Generating Templates from a JSON File
2+
//!
3+
//! This example demonstrates how to use the `generate_from_json` function from the `libmake` crate
4+
//! to generate template files from a JSON file containing configuration data.
5+
//!
6+
//! ## Usage
7+
//!
8+
//! To run this example, ensure that you have a valid JSON file at the specified path.
9+
//! The example defines the path to the JSON file (`json_file_path`) and then calls
10+
//! the `generate_from_json` function with this path as a parameter.
11+
//!
12+
//! If the generation process is successful, it does nothing (the template files are created).
13+
//! If there is an error during generation, it prints an error message.
14+
//!
15+
//! ```rust
16+
//! // Import the necessary function for generating templates from a JSON file.
17+
//! use libmake::generator::generate_from_json;
18+
//!
19+
//! /// This test demonstrates how to use the `generate_from_json` function from the `libmake` crate
20+
//! /// to generate template files from a JSON file.
21+
//!
22+
//! // Define the path to the JSON file that contains configuration data.
23+
//! let json_file_path = "./tests/data/mylibrary.json";
24+
//!
25+
//! // Generate template files based on the data in the JSON file.
26+
//! // If the generation process fails, an error message is printed.
27+
//! generate_from_json(json_file_path)
28+
//! .expect("Failed to generate the template files");
29+
//! ```
30+
31+
// Import the necessary function for generating templates from a JSON file.
132
use libmake::generator::generate_from_json;
33+
34+
/// This test demonstrates how to use the `generate_from_json` function from the `libmake` crate
35+
/// to generate template files from a JSON file.
236
fn main() {
37+
// Define the path to the JSON file that contains configuration data.
338
let json_file_path = "./tests/data/mylibrary.json";
39+
40+
// Generate template files based on the data in the JSON file.
41+
// If the generation process fails, an error message is printed.
442
generate_from_json(json_file_path)
543
.expect("Failed to generate the template files");
644
}

examples/generate_from_toml.rs

+31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
1+
//! # Example: Generating Templates from a TOML File
2+
//!
3+
//! This is a simple example that demonstrates how to generate template files
4+
//! based on configuration stored in a TOML file using the `generate_from_toml`
5+
//! function.
6+
//!
7+
//! ## Usage
8+
//!
9+
//! To run this example, make sure you have a valid TOML configuration file
10+
//! at the specified path. The example will attempt to generate template files
11+
//! based on the configuration. If generation fails, it will print an error
12+
//! message.
13+
//!
14+
//! ```rust
15+
//! // Import the necessary function for generating templates from a TOML file.
16+
//! use libmake::generator::generate_from_toml;
17+
//!
18+
//! // Define the path to the TOML file containing configuration.
19+
//! let toml_file_path = "./tests/data/mylibrary.toml"
20+
//! // Generate template files based on the configuration in the TOML file.
21+
//! // If generation fails, it will print an error message.
22+
//! generate_from_toml(toml_file_path)
23+
//! .expect("Failed to generate the template files");
24+
//! ```
25+
//!
26+
// Import the necessary function for generating templates from a TOML file.
127
use libmake::generator::generate_from_toml;
28+
229
fn main() {
30+
// Define the path to the TOML file containing configuration.
331
let toml_file_path = "./tests/data/mylibrary.toml";
32+
33+
// Generate template files based on the configuration in the TOML file.
34+
// If generation fails, it will print an error message.
435
generate_from_toml(toml_file_path)
536
.expect("Failed to generate the template files");
637
}

examples/generate_from_yaml.rs

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
1+
//! # Example: Generating Templates from a YAML File
2+
//!
3+
//! This is a simple example that demonstrates how to use the `generate_from_yaml` function
4+
//! from the `libmake` crate to generate template files from a YAML file.
5+
//!
6+
//! ## Usage
7+
//!
8+
//! To run this example, make sure you have a valid YAML file at the specified path.
9+
//! The example specifies the path to the YAML file (`yaml_file_path`) and then calls
10+
//! the `generate_from_yaml` function with this path as a parameter.
11+
//!
12+
//! If the generation process is successful, it does nothing (the template files are created).
13+
//! If there is an error during generation, it prints an error message.
14+
//!
15+
//! ```rust
16+
//! // Import the necessary function for generating templates from a YAML file.
17+
//! use libmake::generator::generate_from_yaml;
18+
//!
19+
//! // Specify the path to the YAML file to be used for generating templates.
20+
//! let yaml_file_path = "./tests/data/mylibrary.yaml";
21+
//!
22+
//! // Generate template files from the specified YAML file.
23+
//! generate_from_yaml(yaml_file_path)
24+
//! .expect("Failed to generate the template files");
25+
//! ```
26+
27+
// Import the necessary function for generating templates from a YAML file.
128
use libmake::generator::generate_from_yaml;
29+
230
fn main() {
31+
// Specify the path to the YAML file to be used for generating templates.
332
let yaml_file_path = "./tests/data/mylibrary.yaml";
33+
34+
// Generate template files from the specified YAML file.
435
generate_from_yaml(yaml_file_path)
536
.expect("Failed to generate the template files");
6-
}
37+
}

0 commit comments

Comments
 (0)