How tanakh/cargo-atcoder works
Project type and purpose
• This is a Rust‑based command‑line tool (“cargo‑atcoder”), implemented as a Cargo subcommand, which automates common AtCoder workflows (login, project creation, local testing, submission, status inspection, etc.).
• There is no GUI or server component; it’s a single CLI application that interacts with:
– The user’s file system (to read/write config files and contest projects)
– The AtCoder website over HTTP
– External tools (Cargo/Rust toolchain, optional cross/Docker, UPX/strip)
High‑level file‑structure analysis
• Top‑level files: Cargo.toml, Cargo.lock, README.md, LICENSE, TODO.md
• config/ – default user config template
• data/ – example code for binary runner
• doc/ – images and documentation artifacts
• src/ – core modules: atcoder.rs (AtCoder API wrappers), http.rs (HTTP client/session), config.rs (settings loader), metadata.rs (parsing contest/problem metadata), watch.rs (watch‑and‑rerun feature), main.rs (command dispatch)
• tests/ – integration tests for commands (new, gen‑binary, submit flow…)
• .github/workflows/rust.yml – CI pipeline for building and testing
Key README insights
• Describes subcommands: login, new, test, submit, status, gen‑binary, result
• Explains interactions with AtCoder (login/session storage, scraping problem statements for test cases)
• Explains optional integration with cross/Docker, UPX, custom strip binaries
Main components
a. CLI Entrypoint (main.rs / Clap‑style subcommand dispatcher)
b. Subcommand Modules (atcoder.rs, http.rs, metadata.rs, watch.rs, config.rs)
c. Local File‑System (projects under target‑dir, ~/.config/cargo‑atcoder.toml or macOS plist path)
d. AtCoder External Service (HTTP endpoints: login, problem pages, submission API, result API)
e. Rust Toolchain Subsystem (Cargo build/test, Rustc, optional cross/Docker for cross‑compilation, UPX/strip for binary packing)
f. CI Pipeline (GitHub Actions invoking tests)
Relationships and interactions
– User types “cargo atcoder <subcommand>” → CLI Entrypoint
– Entrypoint loads Config module → config file in ~/.config or ~/Library/Preferences
– Based on subcommand:
• login → HTTP client opens session, stores cookies
• new → Metadata module scrapes contest page, file‑system module creates Cargo project tree
• test → HTTP/metadata fetches sample cases or spawns local “cargo test”
• submit → spawns Cargo build (possibly via cross), optionally UPX→ sends HTTP POST to AtCoder submission endpoint → awaits result
• status/result → polls AtCoder status/result endpoints via HTTP client → prints to user
• gen‑binary → build + optional strip + returns a Rust code binary for submission
– CI pipeline runs “cargo test” to validate modules end‑to‑end
Architectural patterns and design principles
• Single‑process, modular CLI application (subcommand pattern)
• Separation of concerns:
– HTTP session vs. metadata parsing vs. FS operations vs. build orchestration
• Configuration abstraction to allow per‑user and per‑project overrides
• Optional external‑tool integration (cross, UPX, strip) toggled via config