--debug
This commit is contained in:
parent
d96e637cbf
commit
75e40eea18
|
|
@ -50,9 +50,10 @@ This is a modular single-binary Rust utility that fetches Antares B2B product da
|
|||
|
||||
**Artifacts:**
|
||||
- `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
|
||||
- `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`):**
|
||||
- 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`)
|
||||
- No async runtime; synchronous flow is intentional
|
||||
- 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
|
||||
|
|
|
|||
19
src/main.rs
19
src/main.rs
|
|
@ -24,9 +24,14 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
let logger = Logger::init()?;
|
||||
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 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)
|
||||
.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");
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue