@@ -75,15 +75,22 @@ fn main() {
7575 // Resolve the actual drive data directory (supports drive_<letter> subdirs)
7676 let drive_dir = resolve_drive_dir ( & base_dir, & drive_lower) ;
7777
78- // Parse optional --tz argument (default: -7 for PDT)
78+ // Parse optional arguments
7979 let tz_offset = parse_tz_offset ( & args) ;
80+ let custom_bin = parse_bin_path ( & args) ;
8081
8182 // Determine mode
8283 let mode = & args[ 3 ] ;
8384 let rust_output = match mode. as_str ( ) {
8485 "--regenerate" => {
8586 // Regenerate mode: run uffs to produce fresh output
86- regenerate_rust_output ( & drive_dir, & drive_letter, & drive_lower, tz_offset)
87+ regenerate_rust_output (
88+ & drive_dir,
89+ & drive_letter,
90+ & drive_lower,
91+ tz_offset,
92+ custom_bin. as_deref ( ) ,
93+ )
8794 }
8895 "--rust" => {
8996 // Default mode: use provided Rust output file
@@ -212,13 +219,14 @@ fn find_golden_baseline_file(data_dir: &Path, drive_lower: &str) -> PathBuf {
212219
213220fn print_usage ( prog : & str ) {
214221 eprintln ! (
215- "Usage: {} <base_dir> <drive_letter> [--rust <rust_output> | --regenerate] [--tz OFFSET ]" ,
222+ "Usage: {} <base_dir> <drive_letter> [--rust <rust_output> | --regenerate] [OPTIONS ]" ,
216223 prog
217224 ) ;
218225 eprintln ! ( ) ;
219226 eprintln ! ( "Options:" ) ;
220227 eprintln ! ( " --tz OFFSET Timezone offset in hours (default: -7 for PDT)" ) ;
221228 eprintln ! ( " Use -7 for PDT (Pacific Daylight), -8 for PST (Pacific Standard)" ) ;
229+ eprintln ! ( " --bin PATH Path to uffs binary (default: auto-detect from cargo metadata)" ) ;
222230 eprintln ! ( ) ;
223231 eprintln ! ( "The script auto-detects the drive data directory:" ) ;
224232 eprintln ! ( " - New layout: <base_dir>/drive_<letter>/ (e.g., uffs_data/drive_d/)" ) ;
@@ -227,6 +235,10 @@ fn print_usage(prog: &str) {
227235 eprintln ! ( "Examples:" ) ;
228236 eprintln ! ( " {} /Users/rnio/uffs_data F --regenerate" , prog) ;
229237 eprintln ! ( " {} /Users/rnio/uffs_data F --regenerate --tz -8" , prog) ;
238+ eprintln ! (
239+ " {} /Users/rnio/uffs_data F --regenerate --bin ./target/release/uffs" ,
240+ prog
241+ ) ;
230242 eprintln ! (
231243 " {} /Users/rnio/uffs_data D --rust /tmp/rust_output.txt" ,
232244 prog
@@ -243,11 +255,22 @@ fn parse_tz_offset(args: &[String]) -> i32 {
243255 -7 // Default to PDT
244256}
245257
258+ /// Parse --bin argument from command line. Returns None if not specified.
259+ fn parse_bin_path ( args : & [ String ] ) -> Option < PathBuf > {
260+ for i in 0 ..args. len ( ) {
261+ if args[ i] == "--bin" && i + 1 < args. len ( ) {
262+ return Some ( PathBuf :: from ( & args[ i + 1 ] ) ) ;
263+ }
264+ }
265+ None
266+ }
267+
246268fn regenerate_rust_output (
247269 data_dir : & Path ,
248270 drive_letter : & str ,
249271 drive_lower : & str ,
250272 tz_offset : i32 ,
273+ custom_bin : Option < & Path > ,
251274) -> PathBuf {
252275 let tz_str = format ! ( "{}" , tz_offset) ;
253276 let tz_label = match tz_offset {
@@ -271,31 +294,42 @@ fn regenerate_rust_output(
271294 }
272295 println ! ( "MFT file: {}" , mft_file. display( ) ) ;
273296
274- // Locate authoritative workspace release artifact
275- let artifact = find_workspace_release_artifact ( ) ;
276- println ! (
277- "Workspace root: {}" ,
278- artifact. workspace_root. display( )
279- ) ;
280- println ! (
281- "Cargo target dir: {}" ,
282- artifact. cargo_target_dir. display( )
283- ) ;
284- println ! ( "UFFS release artifact: {}" , artifact. binary_path. display( ) ) ;
285- println ! (
286- "Artifact provenance: cargo metadata target_directory → release/{}" ,
287- uffs_binary_name( )
288- ) ;
289- if let Some ( target_dir_warning) = artifact. target_dir_warning {
290- println ! ( "Target dir note: {target_dir_warning}" ) ;
291- }
297+ // Determine which binary to use
298+ let binary_path = if let Some ( custom) = custom_bin {
299+ println ! ( "Using custom binary: {}" , custom. display( ) ) ;
300+ if !custom. exists ( ) {
301+ eprintln ! ( "ERROR: Custom binary not found: {}" , custom. display( ) ) ;
302+ std:: process:: exit ( 1 ) ;
303+ }
304+ custom. to_path_buf ( )
305+ } else {
306+ // Locate authoritative workspace release artifact
307+ let artifact = find_workspace_release_artifact ( ) ;
308+ println ! (
309+ "Workspace root: {}" ,
310+ artifact. workspace_root. display( )
311+ ) ;
312+ println ! (
313+ "Cargo target dir: {}" ,
314+ artifact. cargo_target_dir. display( )
315+ ) ;
316+ println ! ( "UFFS release artifact: {}" , artifact. binary_path. display( ) ) ;
317+ println ! (
318+ "Artifact provenance: cargo metadata target_directory → release/{}" ,
319+ uffs_binary_name( )
320+ ) ;
321+ if let Some ( target_dir_warning) = artifact. target_dir_warning {
322+ println ! ( "Target dir note: {target_dir_warning}" ) ;
323+ }
324+ artifact. binary_path
325+ } ;
292326 println ! ( ) ;
293327
294328 // Generate output
295329 let rust_output = data_dir. join ( format ! ( "verify_rust_{}.txt" , drive_lower) ) ;
296330 println ! ( "Running uffs scan (baseline-compatible algorithms)..." ) ;
297331
298- let status = Command :: new ( & artifact . binary_path )
332+ let status = Command :: new ( & binary_path)
299333 . args ( [
300334 "*" ,
301335 "--mft-file" ,
0 commit comments