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:
@@ -34,13 +34,13 @@ _usaco() {
|
||||
'n:create a problem from template'
|
||||
'from:import a LeetCode problem from its link'
|
||||
"daily:import today's LeetCode daily question"
|
||||
'run:build and run main.cpp'
|
||||
'r:build and run main.cpp'
|
||||
'build:build main.cpp'
|
||||
'b:build main.cpp'
|
||||
'vim:open main.cpp in $EDITOR'
|
||||
'edit:open main.cpp in $EDITOR'
|
||||
'e:open main.cpp in $EDITOR'
|
||||
'run:build and run the solution'
|
||||
'r:build and run the solution'
|
||||
'build:build the solution'
|
||||
'b:build the solution'
|
||||
'vim:open the solution in $EDITOR'
|
||||
'edit:open the solution in $EDITOR'
|
||||
'e:open the solution in $EDITOR'
|
||||
'test:run saved test cases (test create <name> to add one)'
|
||||
't:run saved test cases'
|
||||
'done:mark solved (auto-commits)'
|
||||
@@ -49,10 +49,10 @@ _usaco() {
|
||||
'u:move back to solving'
|
||||
'skip:set aside for later'
|
||||
'sk:set aside for later'
|
||||
'io:show or set the freopen io name'
|
||||
'cat:print main.cpp to stdout'
|
||||
'copy:copy main.cpp to the clipboard'
|
||||
'cp:copy main.cpp to the clipboard'
|
||||
'io:show or set the file-io name'
|
||||
'cat:print the solution to stdout'
|
||||
'copy:copy the solution to the clipboard'
|
||||
'cp:copy the solution to the clipboard'
|
||||
'open:open the saved problem URL'
|
||||
'o:open the saved problem URL'
|
||||
'list:list problems by status'
|
||||
@@ -65,17 +65,20 @@ _usaco() {
|
||||
'clean:delete binaries and backups'
|
||||
'sync:pull website edits, push local commits'
|
||||
'sy:pull website edits, push local commits'
|
||||
'lint:run clippy over the rust solutions and template.rs'
|
||||
'template:same as reset'
|
||||
'tpl:same as reset'
|
||||
'reset:fresh main.cpp from template, delete binary/.out'
|
||||
'rm:fresh main.cpp from template, delete binary/.out'
|
||||
'delete:fresh main.cpp from template, delete binary/.out'
|
||||
'reset:fresh solution from template (cpp/rust switches language), delete binary/.out'
|
||||
'rm:fresh solution from template (cpp/rust switches language), delete binary/.out'
|
||||
'delete:fresh solution from template (cpp/rust switches language), delete binary/.out'
|
||||
'lang:show or set the default language for new problems'
|
||||
)
|
||||
if (( CURRENT == 2 )); then
|
||||
_describe 'command' cmds
|
||||
elif (( CURRENT == 3 )); then
|
||||
case "$words[2]" in
|
||||
i|interactive|repl|new|n|from|daily|list|l|ls|stats|st|clean|sync|sy) ;; # no problem-name argument
|
||||
lang) _values 'language' cpp rust ;;
|
||||
test|t)
|
||||
local -a subs
|
||||
subs=('create:save a new test case' 'add:save a new test case' 'new:save a new test case')
|
||||
@@ -83,8 +86,11 @@ _usaco() {
|
||||
_usaco_problems ;;
|
||||
*) _usaco_problems ;;
|
||||
esac
|
||||
elif (( CURRENT == 4 )) && [[ "$words[2]" == (test|t) && "$words[3]" == (create|add|new) ]]; then
|
||||
_usaco_problems
|
||||
elif (( CURRENT == 4 )); then
|
||||
case "$words[2]" in
|
||||
test|t) [[ "$words[3]" == (create|add|new) ]] && _usaco_problems ;;
|
||||
template|tpl|reset|rm|delete) _values 'language' cpp rust ;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
if (( $+functions[compdef] )); then
|
||||
|
||||
Reference in New Issue
Block a user