Tidy the usaco CLI: prefixes everywhere, LOCAL debug builds, git-based dates
- done/skip/undo accept unique prefixes like every other command - builds define LOCAL (-I repo root): the template includes debugging.h and enables DBG/printV only locally, so main.cpp is submittable as-is - run/build/test --debug (or USACO_DEBUG=1): ASan/UBSan + _GLIBCXX_DEBUG - list/stats date problems by git history, not mtimes reset by checkouts - template/tpl is now an alias of reset (which gains -y); fixes template dropping the STDIO line - run shows <io>.out via detect_io instead of the first *.out - debugging.h: size_t loop indices (no -Wsign-compare noise) - zsh completion for i/cat/copy; README covers test, io, reset, --debug - ignore a.out Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -33,7 +33,19 @@ Creates `solving/<name>/main.cpp` from the template and an empty `.in` file, the
|
||||
./usaco run diamond-collector # compile + run, then print the .out file
|
||||
./usaco build diamond-collector # compile only
|
||||
```
|
||||
Compiles with `g++ -O2 -std=c++17 -Wall -Wextra` and runs inside the problem dir so file IO just works. Put your test input in the `.in` file first.
|
||||
Compiles with `g++ -O2 -std=c++17 -Wall -Wextra -DLOCAL` and runs inside the problem dir so file IO just works. Put your test input in the `.in` file first.
|
||||
|
||||
Add `--debug` to `run`, `build` or `test` (or set `USACO_DEBUG=1`) for a sanitizer build (`-fsanitize=address,undefined`, `_GLIBCXX_DEBUG`): out-of-bounds indexing, overflow and other UB crash with a stack trace instead of silently giving wrong answers.
|
||||
|
||||
**Debug output:** `LOCAL` is only defined by `./usaco` builds, so the template's `#ifdef LOCAL #include "debugging.h"` (pretty-printers for vectors, maps, pairs…) and its `DBG(x)` macros vanish on the judge — submit `main.cpp` as-is.
|
||||
|
||||
### Test cases
|
||||
```
|
||||
./usaco test create diamond-collector # save tests/N.in (current .in, or paste) + expected N.out
|
||||
./usaco test diamond-collector # build, run every saved case, diff, show pass/fail + time
|
||||
./usaco test diamond-collector 2 3 # only cases 2 and 3
|
||||
```
|
||||
Diffs ignore trailing whitespace and trailing blank lines. A case with no `.out` just prints what it produced.
|
||||
|
||||
### Finish (or give up on) a problem
|
||||
```
|
||||
@@ -48,15 +60,15 @@ The website commits too: marking a problem solved/skipped, or editing its link o
|
||||
|
||||
### Edit
|
||||
```
|
||||
./usaco vim diamond-collector # open main.cpp in $EDITOR (defaults to vim)
|
||||
./usaco vim diamond-collector # open main.cpp in $EDITOR (defaults to nvim)
|
||||
./usaco e diamond-collector # same thing, shorter (also: edit)
|
||||
```
|
||||
Opens from inside the problem dir, so the `.in`/`.out` files are right there.
|
||||
|
||||
### Look around
|
||||
```
|
||||
./usaco list # all problems by status, oldest-touched first
|
||||
./usaco stats # counts + problems solved in the last 7 / 30 days
|
||||
./usaco list # all problems by status, oldest-touched first (by last commit; uncommitted work counts as newest)
|
||||
./usaco stats # counts + problems solved in the last 7 / 30 days (by the commit that moved them to solved/)
|
||||
./usaco open diamond-collector # open the saved problem URL in a browser
|
||||
```
|
||||
|
||||
@@ -88,7 +100,9 @@ The selection persists across sessions in `.current` (cleared automatically if t
|
||||
|
||||
### Misc
|
||||
```
|
||||
./usaco template diamond-collector # reset main.cpp from template (old one saved as main.cpp.bak)
|
||||
./usaco reset diamond-collector # fresh main.cpp from template (old one -> main.cpp.bak), delete binary + .out
|
||||
# asks first (-y skips); keeps tests/ and .in (aliases: template, rm)
|
||||
./usaco io diamond-collector # show the io name; 'io <name> <new>' renames .in/.out and rewires STDIO
|
||||
./usaco clean # delete compiled binaries (main, a.out) and .bak files everywhere
|
||||
./usaco path diamond-collector # print the problem's directory
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user