Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the dependencies #19

Merged
merged 2 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [Unreleased]

### Changed

- On `submit` command, now it snows the result before `watch`ing the submission.

### Fixed

- Fixed the parser for AtCoder submissions. ([qryxip/snowchains#71](https://github.com/qryxip/snowchains/pull/71))

## [0.3.0] - 2020-08-06Z

### Changed
Expand Down
72 changes: 46 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ serde = { version = "1.0.114", features = ["derive"] }
serde_json = "1.0.57"
serde_yaml = "0.8.13"
shell-escape = "0.1.5"
snowchains_core = "0.3.0"
structopt = "0.3.15"
strum = { version = "0.18.0", features = ["derive"] }
snowchains_core = "0.3.1"
structopt = "0.3.16"
strum = { version = "0.19.2", features = ["derive"] }
tempfile = "3.1.0"
termcolor = "1.1.0"
tokio = { version = "0.2.22", features = ["signal"] }
toml = "0.5.6"
toml_edit = "0.2.0"
url = { version = "2.1.1", features = ["serde"] }
which = "4.0.1"
which = "4.0.2"

[target.'cfg(windows)'.dependencies]
term_size = "1.0.0-beta.2"
term_size = "=1.0.0-beta.2"
60 changes: 47 additions & 13 deletions src/commands/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ use prettytable::{
row, Table,
};
use snowchains_core::web::{
Atcoder, AtcoderSubmitCredentials, AtcoderSubmitTarget, Codeforces,
CodeforcesSubmitCredentials, CodeforcesSubmitTarget, CookieStorage, Submit, Yukicoder,
YukicoderSubmitCredentials, YukicoderSubmitTarget,
Atcoder, AtcoderSubmitCredentials, AtcoderSubmitTarget, AtcoderWatchSubmissionsCredentials,
AtcoderWatchSubmissionsTarget, Codeforces, CodeforcesSubmitCredentials, CodeforcesSubmitTarget,
CookieStorage, Submit, WatchSubmissions, Yukicoder, YukicoderSubmitCredentials,
YukicoderSubmitTarget,
};
use std::{borrow::BorrowMut as _, cell::RefCell, cmp, path::PathBuf};
use structopt::StructOpt;
Expand Down Expand Up @@ -222,11 +223,10 @@ pub(crate) fn run(opt: OptCompeteSubmit, ctx: crate::Context<'_>) -> anyhow::Res
TargetProblem::Yukicoder(_) => YUKICODER_RUST_LANG_ID,
};

let watch_submission = !no_watch;
let cookie_storage = CookieStorage::with_jsonl(credentials::cookies_path()?)?;
let timeout = crate::web::TIMEOUT;

let outcome = match package_metadata_bin.problem {
let outcome = match &package_metadata_bin.problem {
TargetProblem::Atcoder { contest, index, .. } => {
let shell = RefCell::new(shell.borrow_mut());

Expand All @@ -240,13 +240,13 @@ pub(crate) fn run(opt: OptCompeteSubmit, ctx: crate::Context<'_>) -> anyhow::Res

Atcoder::exec(Submit {
target: AtcoderSubmitTarget {
contest,
problem: index,
contest: contest.clone(),
problem: index.clone(),
},
credentials,
language_id: ATCODER_RUST_LANG_ID.to_owned(),
code,
watch_submission,
watch_submission: false,
cookie_storage,
timeout,
shell: &shell,
Expand All @@ -269,13 +269,13 @@ pub(crate) fn run(opt: OptCompeteSubmit, ctx: crate::Context<'_>) -> anyhow::Res

Codeforces::exec(Submit {
target: CodeforcesSubmitTarget {
contest,
problem: index,
contest: contest.clone(),
problem: index.clone(),
},
credentials,
language_id: CODEFORCES_RUST_LANG_ID.to_owned(),
code,
watch_submission,
watch_submission: false,
cookie_storage,
timeout,
shell: &shell,
Expand All @@ -289,7 +289,7 @@ pub(crate) fn run(opt: OptCompeteSubmit, ctx: crate::Context<'_>) -> anyhow::Res
Yukicoder::exec(Submit {
target: match target_problem {
TargetProblemYukicoder::Contest { contest, index, .. } => {
YukicoderSubmitTarget::Contest(contest, index)
YukicoderSubmitTarget::Contest(contest.clone(), index.clone())
}
TargetProblemYukicoder::Problem { no, .. } => {
YukicoderSubmitTarget::ProblemNo(no.to_string())
Expand All @@ -298,7 +298,7 @@ pub(crate) fn run(opt: OptCompeteSubmit, ctx: crate::Context<'_>) -> anyhow::Res
credentials,
language_id: YUKICODER_RUST_LANG_ID.to_owned(),
code,
watch_submission,
watch_submission: false,
cookie_storage: (),
timeout,
shell: shell.borrow_mut(),
Expand Down Expand Up @@ -327,5 +327,39 @@ pub(crate) fn run(opt: OptCompeteSubmit, ctx: crate::Context<'_>) -> anyhow::Res

write!(shell.err(), "{}", table)?;
shell.err().flush()?;

if !no_watch {
let cookie_storage = CookieStorage::with_jsonl(credentials::cookies_path()?)?;
let timeout = crate::web::TIMEOUT;

match package_metadata_bin.problem {
TargetProblem::Atcoder { contest, .. } => {
let shell = RefCell::new(shell);

let credentials = AtcoderWatchSubmissionsCredentials {
username_and_password: &mut credentials::username_and_password(
&shell,
"Username: ",
"Password: ",
),
};

Atcoder::exec(WatchSubmissions {
target: AtcoderWatchSubmissionsTarget { contest },
credentials,
cookie_storage,
timeout,
shell: &shell,
})?;
}
TargetProblem::Codeforces { .. } => {
shell.warn("watching submissions for Codeforces is not implemented")?;
}
TargetProblem::Yukicoder(_) => {
shell.warn("watching submissions for yukicoder is not implemented")?;
}
}
}

Ok(())
}