This commit is contained in:
Villers Krisztián 2026-05-05 22:19:04 +02:00
parent d96e637cbf
commit 75e40eea18
2 changed files with 24 additions and 2 deletions

View File

@ -50,9 +50,10 @@ This is a modular single-binary Rust utility that fetches Antares B2B product da
**Artifacts:** **Artifacts:**
- `temp/antares.json` - saved in `temp/` after each successful API fetch; directory created auto if missing - `temp/antares.json` - saved in `temp/` after each successful API fetch; directory created auto if missing
- **Cleanup**: `temp/` directory is automatically deleted after Excel export (unless `--debug` flag is set)
- Excel export path is configured via the `OUT` env var; parent directory created auto if missing - Excel export path is configured via the `OUT` env var; parent directory created auto if missing
- `log/{YYYY-MM-DD}.log` - daily logs; `log/` directory created auto if missing - `log/{YYYY-MM-DD}.log` - daily logs; `log/` directory created auto if missing
- `.gitignore` excludes: `*.json`, `*.xlsx`, `.env`, `/out`, `/log` - `.gitignore` excludes: `*.json`, `*.xlsx`, `.env`, `/out`, `/log`, `/temp`
**Excel export (`src/tools/excel.rs`):** **Excel export (`src/tools/excel.rs`):**
- Not a generic dump; maps selected Antares fields to fixed column layout per business rules - Not a generic dump; maps selected Antares fields to fixed column layout per business rules
@ -75,3 +76,7 @@ This is a modular single-binary Rust utility that fetches Antares B2B product da
- Uses `reqwest::blocking::Client` with 600-second timeout (in `src/tools/request.rs`) - Uses `reqwest::blocking::Client` with 600-second timeout (in `src/tools/request.rs`)
- No async runtime; synchronous flow is intentional - No async runtime; synchronous flow is intentional
- Only change to async if architecture overhaul is deliberate - Only change to async if architecture overhaul is deliberate
**CLI Arguments:**
- `--config /path/to/.env` - Load config from custom location (defaults to `.env` in current directory)
- `--debug` - Enable debug mode: preserves `temp/` directory for inspection, no cleanup after export

View File

@ -24,9 +24,14 @@ fn main() -> Result<(), Box<dyn Error>> {
let logger = Logger::init()?; let logger = Logger::init()?;
logger.info("Starting Antares data export"); logger.info("Starting Antares data export");
// Parse CLI arguments for --config flag // Parse CLI arguments for --config and --debug flags
let args: Vec<String> = std::env::args().collect(); let args: Vec<String> = std::env::args().collect();
let config_path = parse_config_arg(&args); let config_path = parse_config_arg(&args);
let debug_mode = args.contains(&"--debug".to_string());
if debug_mode {
logger.debug("Debug mode enabled - temp files will be preserved");
}
let env_config = load_env_config(config_path) let env_config = load_env_config(config_path)
.map_err(|e| { .map_err(|e| {
@ -116,6 +121,18 @@ fn main() -> Result<(), Box<dyn Error>> {
} }
} }
// Clean up temp directory unless in debug mode
if !debug_mode {
match fs::remove_dir_all(&temp_dir) {
Ok(_) => {
logger.debug(&format!("Cleaned up temp directory: {:?}", temp_dir));
}
Err(e) => {
logger.warn(&format!("Failed to remove temp directory '{:?}': {}", temp_dir, e));
}
}
}
logger.info("Export process completed successfully"); logger.info("Export process completed successfully");
Ok(()) Ok(())
} }