Skip to content

Commit

Permalink
feat(build): support --file-list
Browse files Browse the repository at this point in the history
This add support to pass a file with a list (lines) of content
files to build.
  • Loading branch information
fiji-flo committed Feb 14, 2025
1 parent da781c5 commit fe44b01
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion crates/rari-cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::env;
use std::fs::{self, File};
use std::io::{BufWriter, Write};
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::mpsc::channel;
use std::sync::Arc;
use std::thread::spawn;
Expand Down Expand Up @@ -38,6 +39,7 @@ use rari_tools::sync_translated_content::sync_translated_content;
use rari_types::globals::{build_out_root, content_root, content_translated_root, SETTINGS};
use rari_types::locale::Locale;
use rari_types::settings::Settings;
use rari_utils::io::read_to_string;
use schemars::schema_for;
use self_update::cargo_crate_version;
use tabwriter::TabWriter;
Expand Down Expand Up @@ -169,6 +171,8 @@ struct ServeArgs {
struct BuildArgs {
#[arg(short, long, help = "Build only content <FILES>")]
files: Vec<PathBuf>,
#[arg(short, long, help = "Build only content listed in <FILE_LIST>")]
file_list: Option<PathBuf>,
#[arg(short, long, help = "Abort build on warnings")]
deny_warnings: bool,
#[arg(long, help = "Disable caching (only for debugging)")]
Expand Down Expand Up @@ -283,12 +287,22 @@ fn main() -> Result<(), Error> {
settings.json_issues = args.json_issues;
let _ = SETTINGS.set(settings);

let arg_files = args
let mut arg_files = args
.files
.iter()
.map(|path| path.canonicalize())
.collect::<Result<Vec<PathBuf>, _>>()?;

if let Some(file_list) = args.file_list {
arg_files.extend(
read_to_string(&file_list)?
.lines()
.filter(|s| !s.is_empty())
.map(|line| Ok(PathBuf::from_str(line)?.canonicalize()?))
.collect::<Result<Vec<PathBuf>, Error>>()?,
);
}

let templ_stats = if args.templ_stats {
let (tx, rx) = channel::<String>();
TEMPL_RECORDER_SENDER
Expand Down

0 comments on commit fe44b01

Please sign in to comment.