added support for globs in pi.ron

This commit is contained in:
JOLIMAITRE Matthieu 2023-01-04 15:54:36 +01:00
parent ad18c69f28
commit 058ea6a2f0
4 changed files with 16 additions and 9 deletions

2
Cargo.lock generated
View file

@ -138,7 +138,7 @@ checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
[[package]] [[package]]
name = "epitls-pi" name = "epitls-pi"
version = "1.4.1" version = "1.5.0"
dependencies = [ dependencies = [
"chrono", "chrono",
"clap", "clap",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "epitls-pi" name = "epitls-pi"
version = "1.4.1" version = "1.5.0"
edition = "2021" edition = "2021"
license = "GPL-3.0+" license = "GPL-3.0+"
description = "A little helper tool meant to ease the developpment of the C piscine at EPITA/Toulouse." description = "A little helper tool meant to ease the developpment of the C piscine at EPITA/Toulouse."

View file

@ -94,6 +94,16 @@ impl Config {
self.includes self.includes
.iter() .iter()
.map(|p| Self::try_absolute(p.clone())) .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() .collect()
} }

View file

@ -1,5 +1,3 @@
use std::env;
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
use config::Config; use config::Config;
@ -67,10 +65,10 @@ pub enum Commands {
/// Initializes a project directory configuration, useful for custom flags, includes and custop push messages. /// Initializes a project directory configuration, useful for custom flags, includes and custop push messages.
init { init {
/// Identifier for the automated tests.
prefix: String,
/// Path to the folder containing the project. /// Path to the folder containing the project.
path: Option<String>, path: String,
/// Identifier for the automated tests.
prefix: Option<String>,
/// e /// e
#[clap(short, long)] #[clap(short, long)]
tests: bool, tests: bool,
@ -151,8 +149,7 @@ fn main() {
prefix, prefix,
tests, tests,
} => { } => {
let path = let prefix = prefix.unwrap_or_else(|| ".".to_string());
path.unwrap_or_else(|| env::current_dir().unwrap().to_str().unwrap().to_string());
let prefix = prefix.trim().trim_end_matches('*'); let prefix = prefix.trim().trim_end_matches('*');
config::create(path.clone(), prefix.to_string()); config::create(path.clone(), prefix.to_string());
if tests { if tests {