# usaco lint [name...] # Regenerates the cargo manifest rust-analyzer reads, then runs clippy over the # rust solutions. With no arguments it lints every one, plus template.rs; names # select individual problems (unique prefixes work, as everywhere else), and # the literal name "template" selects template.rs. command -v cargo >/dev/null || { echo "Error: cargo not found" >&2; exit 1; } count="$(sync_cargo_manifest)" if [[ -z "$count" ]]; then echo "No rust solutions or template.rs yet — nothing to lint." exit 0 fi targets=() for name in "$@"; do if [[ "$name" == template ]]; then [[ -f "$ROOT/template.rs" ]] || { echo "Error: template.rs not found" >&2; exit 1; } targets+=(--bin template) continue fi dir="$(find_problem "$name")" || exit 1 [[ -f "$dir/main.rs" ]] || { echo "Error: $(basename "$dir") is not a rust problem" >&2; exit 1; } rel="${dir#"$ROOT"/}" targets+=(--bin "${rel%/*}-${rel##*/}") done if [[ ${#targets[@]} -eq 0 ]]; then what="$count rust solution(s)" [[ -f "$ROOT/template.rs" ]] && what+=" and template.rs" echo "${DIM}Linting $what...${RST}" targets=(--bins) fi # Builds live under target/, away from the ./main binaries usaco produces. (cd "$ROOT" && cargo clippy --quiet "${targets[@]}")