From 058ea6a2f005401b9ed3223d299b90838bc7989a Mon Sep 17 00:00:00 2001 From: JOLIMAITRE Matthieu Date: Wed, 4 Jan 2023 15:54:36 +0100 Subject: [PATCH] added support for globs in pi.ron --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/config.rs | 10 ++++++++++ src/main.rs | 11 ++++------- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4366547..39a505d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,7 +138,7 @@ checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" [[package]] name = "epitls-pi" -version = "1.4.1" +version = "1.5.0" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 136ea53..21a8b9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "epitls-pi" -version = "1.4.1" +version = "1.5.0" edition = "2021" license = "GPL-3.0+" description = "A little helper tool meant to ease the developpment of the C piscine at EPITA/Toulouse." diff --git a/src/config.rs b/src/config.rs index 0db4e9e..f13f95d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -94,6 +94,16 @@ impl Config { self.includes .iter() .map(|p| Self::try_absolute(p.clone())) + .flat_map(|p| { + if p.contains('*') { + glob::glob(&p) + .unwrap() + .map(|p| p.unwrap().to_str().unwrap().to_string()) + .collect() + } else { + vec![p] + } + }) .collect() } diff --git a/src/main.rs b/src/main.rs index 426d6a1..547288f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,3 @@ -use std::env; - use clap::{Parser, Subcommand}; use config::Config; @@ -67,10 +65,10 @@ pub enum Commands { /// Initializes a project directory configuration, useful for custom flags, includes and custop push messages. init { - /// Identifier for the automated tests. - prefix: String, /// Path to the folder containing the project. - path: Option, + path: String, + /// Identifier for the automated tests. + prefix: Option, /// e #[clap(short, long)] tests: bool, @@ -151,8 +149,7 @@ fn main() { prefix, tests, } => { - let path = - path.unwrap_or_else(|| env::current_dir().unwrap().to_str().unwrap().to_string()); + let prefix = prefix.unwrap_or_else(|| ".".to_string()); let prefix = prefix.trim().trim_end_matches('*'); config::create(path.clone(), prefix.to_string()); if tests {