Files
adamfandClaude Opus 5.5 1aee0050a0 Add Rust support: usaco lang, lint, and main.rs problems
Brings in the stashed Rust work, merged onto the current CLI. A
problem's language is whichever source it has (main.cpp or main.rs);
'usaco lang' sets the default for new problems (.lang, or $USACO_LANG),
and 'new --rust/--cpp' picks per problem. template.rs is a paste-ready
Rust template whose stdio() uses <io>.in/.out when present and
stdin/stdout otherwise.

run/test now feed <io>.in on stdin and capture stdout when the program
doesn't write <io>.out itself, so Codeforces-style solutions work too.
'reset <name> rust|cpp' switches a problem's language (template is
still an alias), and --debug builds Rust with overflow checks and debug
assertions. 'usaco lint' runs clippy through a generated, gitignored
Cargo.toml that also gives rust-analyzer a project; done/skip/undo
keep it in step. LeetCode imports stay C++.

Also: done stages solved/ and solving/ separately, so a problem that
was never committed from solving/ still gets its "Solve" commit, and
the site lists main.rs ahead of other files like it does main.cpp.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 21:17:50 +01:00

16 lines
915 B
Bash

# usaco done <name>
[[ $# -ge 1 ]] || usage
dir="$(find_problem "$1")"; name="$(basename "$dir")"
[[ "$dir" == "$ROOT/solving/$name" ]] || { echo "Error: $name is not in solving/ (it's in ${dir#$ROOT/})" >&2; exit 1; }
[[ -d "$ROOT/solved/$name" ]] && { echo "Error: solved/$name already exists" >&2; exit 1; }
mv "$ROOT/solving/$name" "$ROOT/solved/$name"
sync_cargo_manifest >/dev/null # the bin paths just moved
echo "Moved to solved/$name 🎉"
if git -C "$ROOT" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
# separately: one pathspec that matches nothing (a problem never committed
# from solving/) would make git refuse to stage the other
git -C "$ROOT" add -A "solved/$name" 2>/dev/null || true
git -C "$ROOT" add -A "solving/$name" 2>/dev/null || true
git -C "$ROOT" commit -m "Solve $name" >/dev/null && echo "Committed: Solve $name ${DIM}(usaco sync to publish it)${RST}"
fi