From a39e120e3fa6723c7ad8c4d27afca79233947935 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Fri, 30 Dec 2022 13:43:32 +0000 Subject: feat(target): allow limiting the generated entrypoints Introduces the `-t/--target` flag that can be used to provide a path. Only entry points that have this path as a prefix will be generated. --- README.md | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 5bd146e..b876bb8 100644 --- a/README.md +++ b/README.md @@ -124,12 +124,19 @@ if !id.is_empty() { .into_iter() .find_map(|(k,p)| if k == "path" { Some(p.clone()) } else { None }); if entry || path.is_some() || PATH.is_match(id) { - Key::Entry(PathBuf::from(path.unwrap_or_default()).join(id)) + let path = PathBuf::from(path.unwrap_or_default()).join(id); + if path.starts_with(&target) { + Some(Key::Entry(path)) + } else { + None + } } else { - Key::Macro(id.to_string()) + Some(Key::Macro(id.to_string())) } }; - <> + if let Some(key) = key { + <> + } } else { eprintln!("Ignoring code block without ID:"); eprintln!("{}", indent(Cow::from(code),4)); @@ -231,6 +238,7 @@ The `struct` holding the CLI information is defined as follow struct Config { <> <> + <> <> } ``` @@ -241,6 +249,8 @@ and the arguments are parsed as let config = Config::parse(); ``` +## Input files + `pangler` accepts a sequence of files that will be parsed, code will be collected and used to build the final program. Note that the order of the file provided on the CLI is important when using the [overriding functionality](#writing-programs). @@ -249,6 +259,25 @@ Note that the order of the file provided on the CLI is important when using the input: Vec, ``` +## Specifying target entry points + +By default `pangler` will generate all entry points gathered from the input file(s). +This behaviour can be overridden with the `-t/--target` flag. + +```{#config_target .rust} +/// Target files prefix +#[clap(short, long)] +target: Option, +``` + +```{#config_parse .rust} +let target = config.target.unwrap_or_default(); +``` + +Any entry point that does not have the provided target *as a prefix* will be ignored. + +## Custom output folder + By default, files are generated in the current working directory. ```{#constants .rust} @@ -256,6 +285,7 @@ const BASE: &str = "./"; ``` This behaviour can be overridden using the `-o`/`--output` flag. +If the output folder does not exists, *it will be created*. ```{#config_output .rust} /// Base output directory [default: './'] @@ -263,6 +293,8 @@ This behaviour can be overridden using the `-o`/`--output` flag. output: Option, ``` +## Limiting recursion depth + Finally, recursive substitution of blocks can lead to an infinite loop. By default, `pangler` will stop after 10 substitution iterations, but this parameter can be changed with the `-d`/`--depth` flag. -- cgit v1.2.3