atcoder_auto_tester/
config.rs1use std::fs;
2use std::path;
3
4use serde_derive::Deserialize;
5
6use crate::error::ErrorHandleable;
7
8#[derive(Deserialize, Debug)]
9pub struct Config {
10 pub command: String,
11 pub file_name: String,
12 pub task_url: String,
13}
14
15impl Config {
16 pub fn load(file: &path::Path) -> Config {
17 let file_name = file.to_string_lossy();
18 let text = fs::read_to_string(file)
19 .handle_error(&format!("Failed to read a config file '{}'", file_name));
20 toml::from_str(&text)
21 .handle_error(&format!("Failed to parse a config file '{}'", file_name))
22 }
23}