atcoder_auto_tester/
app.rs1use std::fs;
2use std::path;
3use std::process;
4
5use crate::args::Args;
6use crate::command::Command;
7use crate::config::Config;
8use crate::detector::Detector;
9use crate::runner::Runner;
10
11pub struct App;
12
13impl App {
14 pub fn clean(test_dir: &path::Path) -> ! {
15 if test_dir.exists() {
16 fs::remove_dir_all(&test_dir).expect("Failed to delete a test directory");
17 }
18 process::exit(0)
19 }
20
21 pub fn login() -> ! {
22 let exit_status = Command::new("oj")
23 .arg("login")
24 .arg("https://atcoder.jp/")
25 .show()
26 .run();
27 Self::exit(exit_status)
28 }
29
30 pub fn run(args: Args, config: Config) -> ! {
31 let detector = Detector::new();
32 let runner = Runner::new(args, config);
33 for file_name in detector.into_iter() {
34 runner.run(&file_name);
35 }
36 unreachable!();
37 }
38
39 fn exit(exit_status: process::ExitStatus) -> ! {
40 process::exit(exit_status.code().unwrap_or(1))
41 }
42}