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]>
This commit is contained in:
@@ -9,32 +9,40 @@
|
||||
# r / t / e act on the current problem
|
||||
# !cmd run a shell command in the problem dir
|
||||
# q quit
|
||||
# usaco new <name> [io-name] [--url <link>]
|
||||
# Create solving/<name> from template.cpp
|
||||
# (io-name sets freopen filenames, defaults to <name>)
|
||||
# usaco new <name> [io-name] [--url <link>] [--rust|--cpp]
|
||||
# Create solving/<name> from template.cpp or template.rs
|
||||
# (io-name sets the file-io name, defaults to <name>;
|
||||
# language defaults to 'usaco lang', see below)
|
||||
# usaco new <leetcode-url> Import a LeetCode problem (alias: from): statement in
|
||||
# problem.md, C++ starter + generated driver.h, the examples
|
||||
# as tests/ with expected outputs
|
||||
# usaco daily Same, for today's LeetCode daily question
|
||||
# usaco run <name> Build main.cpp and run it (in the problem dir)
|
||||
# usaco build <name> Build main.cpp only
|
||||
# usaco lang [cpp|rust] Show or set the default language for 'usaco new'
|
||||
# ($USACO_LANG wins for a single shell)
|
||||
# usaco run <name> Build the solution and run it (in the problem dir)
|
||||
# usaco build <name> Build only
|
||||
# usaco done <name> Move solving/<name> -> solved/<name> and git commit
|
||||
# usaco undo <name> Move solved/ or skipped/<name> -> solving/<name>
|
||||
# usaco skip <name> Move solving/<name> -> skipped/<name>
|
||||
# usaco io <name> [io-name] Show the problem's io name, or set it: renames <old>.in/.out
|
||||
# and rewires STDIO("...") in main.cpp (adds it if missing)
|
||||
# usaco cat <name> Print the problem's main.cpp to stdout (pipeable)
|
||||
# usaco copy <name> Copy the problem's main.cpp to the clipboard (alias: cp)
|
||||
# usaco vim <name> Open the problem's main.cpp in $EDITOR (aliases: edit, e)
|
||||
# and rewires STDIO("...") / stdio("...") in the source
|
||||
# usaco cat <name> Print the problem's solution to stdout (pipeable)
|
||||
# usaco copy <name> Copy the problem's solution to the clipboard (alias: cp)
|
||||
# usaco vim <name> Open the problem's solution in $EDITOR (aliases: edit, e)
|
||||
# usaco open <name> Open the problem's saved URL in a browser
|
||||
# usaco list List problems by status
|
||||
# usaco stats Show solve counts and recent activity
|
||||
# usaco path <name> Print the problem's directory (used by the ucd shell helper)
|
||||
# usaco clean Delete compiled binaries and backups from all problem dirs
|
||||
# usaco sync git pull --rebase (picks up edits made on the website), then push
|
||||
# usaco reset <name> [-y] Reset the solution: fresh main.cpp from template (STDIO wired up,
|
||||
# old one saved as main.cpp.bak), delete binary + .out; keeps tests/
|
||||
# and .in. Asks first unless -y (aliases: rm, delete, template, tpl)
|
||||
# usaco lint [name...] Run clippy over the rust solutions (all of them, or just the
|
||||
# named ones; "template" lints template.rs) and refresh the
|
||||
# Cargo.toml rust-analyzer reads
|
||||
# usaco reset <name> [lang] [-y]
|
||||
# Reset the solution: fresh source from template (io wired up,
|
||||
# old one saved as .bak), delete binary + .out; keeps tests/ and
|
||||
# .in. cpp/rust switches the problem's language. Asks first
|
||||
# unless -y (aliases: rm, delete, template, tpl)
|
||||
# usaco test create <name> Save a test case: uses the current .in (or lets you paste one),
|
||||
# then asks for the expected output. Stored in tests/N.in + N.out
|
||||
# usaco test <name> [nums...] Build and run every saved test case (or just the given ones),
|
||||
@@ -74,6 +82,8 @@ case "$cmd" in
|
||||
path|p) cmd=path ;;
|
||||
clean) cmd=clean ;;
|
||||
sync|sy) cmd=sync ;;
|
||||
lang) cmd=lang ;;
|
||||
lint) cmd=lint ;;
|
||||
reset|rm|delete|template|tpl) cmd=reset ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user