aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md38
1 files changed, 35 insertions, 3 deletions
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() {
124 .into_iter() 124 .into_iter()
125 .find_map(|(k,p)| if k == "path" { Some(p.clone()) } else { None }); 125 .find_map(|(k,p)| if k == "path" { Some(p.clone()) } else { None });
126 if entry || path.is_some() || PATH.is_match(id) { 126 if entry || path.is_some() || PATH.is_match(id) {
127 Key::Entry(PathBuf::from(path.unwrap_or_default()).join(id)) 127 let path = PathBuf::from(path.unwrap_or_default()).join(id);
128 if path.starts_with(&target) {
129 Some(Key::Entry(path))
130 } else {
131 None
132 }
128 } else { 133 } else {
129 Key::Macro(id.to_string()) 134 Some(Key::Macro(id.to_string()))
130 } 135 }
131 }; 136 };
132 <<code_block>> 137 if let Some(key) = key {
138 <<code_block>>
139 }
133} else { 140} else {
134 eprintln!("Ignoring code block without ID:"); 141 eprintln!("Ignoring code block without ID:");
135 eprintln!("{}", indent(Cow::from(code),4)); 142 eprintln!("{}", indent(Cow::from(code),4));
@@ -231,6 +238,7 @@ The `struct` holding the CLI information is defined as follow
231struct Config { 238struct Config {
232 <<config_depth>> 239 <<config_depth>>
233 <<config_output>> 240 <<config_output>>
241 <<config_target>>
234 <<config_input>> 242 <<config_input>>
235} 243}
236``` 244```
@@ -241,6 +249,8 @@ and the arguments are parsed as
241let config = Config::parse(); 249let config = Config::parse();
242``` 250```
243 251
252## Input files
253
244`pangler` accepts a sequence of files that will be parsed, code will be collected and used to build the final program. 254`pangler` accepts a sequence of files that will be parsed, code will be collected and used to build the final program.
245Note that the order of the file provided on the CLI is important when using the [overriding functionality](#writing-programs). 255Note that the order of the file provided on the CLI is important when using the [overriding functionality](#writing-programs).
246 256
@@ -249,6 +259,25 @@ Note that the order of the file provided on the CLI is important when using the
249input: Vec<PathBuf>, 259input: Vec<PathBuf>,
250``` 260```
251 261
262## Specifying target entry points
263
264By default `pangler` will generate all entry points gathered from the input file(s).
265This behaviour can be overridden with the `-t/--target` flag.
266
267```{#config_target .rust}
268/// Target files prefix
269#[clap(short, long)]
270target: Option<PathBuf>,
271```
272
273```{#config_parse .rust}
274let target = config.target.unwrap_or_default();
275```
276
277Any entry point that does not have the provided target *as a prefix* will be ignored.
278
279## Custom output folder
280
252By default, files are generated in the current working directory. 281By default, files are generated in the current working directory.
253 282
254```{#constants .rust} 283```{#constants .rust}
@@ -256,6 +285,7 @@ const BASE: &str = "./";
256``` 285```
257 286
258This behaviour can be overridden using the `-o`/`--output` flag. 287This behaviour can be overridden using the `-o`/`--output` flag.
288If the output folder does not exists, *it will be created*.
259 289
260```{#config_output .rust} 290```{#config_output .rust}
261/// Base output directory [default: './'] 291/// Base output directory [default: './']
@@ -263,6 +293,8 @@ This behaviour can be overridden using the `-o`/`--output` flag.
263output: Option<PathBuf>, 293output: Option<PathBuf>,
264``` 294```
265 295
296## Limiting recursion depth
297
266Finally, recursive substitution of blocks can lead to an infinite loop. 298Finally, recursive substitution of blocks can lead to an infinite loop.
267By default, `pangler` will stop after 10 substitution iterations, but this parameter can be changed with the `-d`/`--depth` flag. 299By default, `pangler` will stop after 10 substitution iterations, but this parameter can be changed with the `-d`/`--depth` flag.
268 300