use skaldpress::macro_processor::error::SMPError; use skaldpress::macro_processor::macro_processor::{MacroProcessorWarning, MacroType}; use skaldpress::skaldpress::filelists::{make_filelist, FileList, FileListFileTargetAction}; use skaldpress::skaldpress::parseopts::{parseopts, Opts}; use std::cmp::Ordering; use std::collections::HashMap; use std::collections::VecDeque; use std::fs; use std::path::Path; use std::time::Instant; use skaldpress::macro_processor::MacroProcessor; use skaldpress::skaldpress::error::SkaldpressError; use skaldpress::skaldpress::error::{ SP_COMPILE_FILE_EXTENSION_ERROR_2, SP_COMPILE_FILE_MACRO_PROCESS_ERROR, SP_COMPILE_FILE_TEMPLATE_READ_ERROR, SP_COMPILE_TEMPLATE_MACRO_PROCESS_ERROR, SP_GEN_DEST_STRIP_PREFIX_ERROR, }; use skaldpress::skaldpress::metadata_parser::extract_parse_yaml_metadata; use skaldpress::skaldpress::metadata_parser::YamlValue; /// Convenience function for doing cmp on a metadata key of two arbitrary indexes /// This takes a macro_processor as input, so that it can emit warnings if the ordering failed in /// any way. fn order_index_by_cached_data( smp: &mut MacroProcessor, key: &str, a: &usize, b: &usize, ) -> Ordering { let compiled_files: &Vec; unsafe { compiled_files = COMPILED_FILES.as_ref(); } if *a >= compiled_files.len() { smp.warnings.push(MacroProcessorWarning::new(format!( "\"a\" is not a cached file {} >= {}", *a, compiled_files.len() ))); return Ordering::Equal; } if *b >= compiled_files.len() { smp.warnings.push(MacroProcessorWarning::new(format!( "\"b\" is not a cached file {} >= {}", *b, compiled_files.len() ))); return Ordering::Equal; } let Some(a) = &compiled_files[*a].metadata.get(key) else { smp.warnings.push(MacroProcessorWarning::new(format!( "Key {:?} not found for ordering data in {:?}", key, compiled_files[*a].source_path ))); return Ordering::Equal; }; let Some(b) = &compiled_files[*b].metadata.get(key) else { smp.warnings.push(MacroProcessorWarning::new(format!( "Key {:?} not found for ordering data in {:?}", key, compiled_files[*b].source_path ))); return Ordering::Equal; }; a.cmp(b) } /// SMP Macro for getting all files with specific tag, this is only _really_ effective the second run /// /// Usage in files: /// all_tagged_by(,