16 lines
656 B
Bash
16 lines
656 B
Bash
# usaco reset/rm/delete <name>
|
|
[[ $# -ge 1 ]] || usage
|
|
dir="$(find_problem "$1")"
|
|
name="$(basename "$dir")"
|
|
io="$(detect_io "$dir" || true)"
|
|
io="${io:-$name}"
|
|
echo "This resets ${dir#$ROOT/} to a fresh template:"
|
|
echo " main.cpp -> re-created from template (old one saved as main.cpp.bak)"
|
|
echo " removes compiled binary and $io.out (tests/ and $io.in are kept)"
|
|
read -r -p "Reset '$name'? [y/N] " ans
|
|
[[ "$ans" == y || "$ans" == Y ]] || { echo "Aborted."; exit 1; }
|
|
[[ -f "$dir/main.cpp" ]] && cp "$dir/main.cpp" "$dir/main.cpp.bak"
|
|
fresh_main "$dir" "$io"
|
|
rm -f "$dir/main" "$dir/a.out" "$dir/$io.out"
|
|
echo "Reset $name (old solution in main.cpp.bak)"
|