Skip to content

Commit fe44b01

Browse files
committed
feat(build): support --file-list
This add support to pass a file with a list (lines) of content files to build.
1 parent da781c5 commit fe44b01

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

crates/rari-cli/main.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::env;
44
use std::fs::{self, File};
55
use std::io::{BufWriter, Write};
66
use std::path::PathBuf;
7+
use std::str::FromStr;
78
use std::sync::mpsc::channel;
89
use std::sync::Arc;
910
use std::thread::spawn;
@@ -38,6 +39,7 @@ use rari_tools::sync_translated_content::sync_translated_content;
3839
use rari_types::globals::{build_out_root, content_root, content_translated_root, SETTINGS};
3940
use rari_types::locale::Locale;
4041
use rari_types::settings::Settings;
42+
use rari_utils::io::read_to_string;
4143
use schemars::schema_for;
4244
use self_update::cargo_crate_version;
4345
use tabwriter::TabWriter;
@@ -169,6 +171,8 @@ struct ServeArgs {
169171
struct BuildArgs {
170172
#[arg(short, long, help = "Build only content <FILES>")]
171173
files: Vec<PathBuf>,
174+
#[arg(short, long, help = "Build only content listed in <FILE_LIST>")]
175+
file_list: Option<PathBuf>,
172176
#[arg(short, long, help = "Abort build on warnings")]
173177
deny_warnings: bool,
174178
#[arg(long, help = "Disable caching (only for debugging)")]
@@ -283,12 +287,22 @@ fn main() -> Result<(), Error> {
283287
settings.json_issues = args.json_issues;
284288
let _ = SETTINGS.set(settings);
285289

286-
let arg_files = args
290+
let mut arg_files = args
287291
.files
288292
.iter()
289293
.map(|path| path.canonicalize())
290294
.collect::<Result<Vec<PathBuf>, _>>()?;
291295

296+
if let Some(file_list) = args.file_list {
297+
arg_files.extend(
298+
read_to_string(&file_list)?
299+
.lines()
300+
.filter(|s| !s.is_empty())
301+
.map(|line| Ok(PathBuf::from_str(line)?.canonicalize()?))
302+
.collect::<Result<Vec<PathBuf>, Error>>()?,
303+
);
304+
}
305+
292306
let templ_stats = if args.templ_stats {
293307
let (tx, rx) = channel::<String>();
294308
TEMPL_RECORDER_SENDER

0 commit comments

Comments
 (0)