updated tests and files to make more test friendly

This commit was merged in pull request #9.
This commit is contained in:
2025-10-06 15:05:09 -05:00
committed by Jason Ross
parent 7ee08f9cb2
commit 70fea045d2
3 changed files with 789 additions and 4 deletions
+21 -4
View File
@@ -221,11 +221,28 @@ fn determine_location(args: &Args) -> Result<(Location, Config), Box<dyn std::er
println!("Using location from command-line: {:.4}, {:.4}", loc.lat, loc.lon);
}
// Still load config for other settings
// Load config for other settings
let mut config = Config::load().unwrap_or_default();
// Update config with manual location
config.set_location(loc, LocationSource::Manual, None);
config.save().ok(); // Ignore save errors
// Only ask to save if running in interactive mode (not print, not one-shot)
if !args.print && !args.one_shot {
use dialoguer::Confirm;
let should_save = Confirm::new()
.with_prompt("Save this location for future use?")
.default(false)
.interact()
.unwrap_or(false);
if should_save {
config.set_location(loc, LocationSource::Manual, None);
config.save().ok(); // Ignore save errors
if args.verbose {
println!("Location saved to configuration file.");
}
} else if args.verbose {
println!("Location will not be saved (session only).");
}
}
return Ok((loc, config));
}