use super::Command;
use async_trait::async_trait;
use clap::{App, ArgMatches};
pub struct ExecCommand;
#[async_trait]
impl Command for ExecCommand {
fn usage<'a, 'edit>() -> App<'a, 'edit> {
use clap::{Arg, SubCommand};
SubCommand::with_name("exec")
.about("Submit solution")
.visible_alias("x")
.arg(
Arg::with_name("id")
.takes_value(true)
.required(true)
.help("question id"),
)
}
async fn handler(m: &ArgMatches<'_>) -> Result<(), crate::Error> {
use crate::cache::{Cache, Run};
let id: i32 = m.value_of("id")?.parse()?;
let cache = Cache::new()?;
let res = cache.exec_problem(id, Run::Submit, None).await?;
println!("{}", res);
Ok(())
}
}