From: Javier Sagredo Date: Thu, 18 Jun 2026 22:48:34 +0000 (+0200) Subject: Give classgraph-plugin-flag.sh a real --help X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=4a2748415b892e48d31d032414aba67990d649bf;p=classgraph.git Give classgraph-plugin-flag.sh a real --help The previous -h/--help ran a sed that quit at the first lone '#' (line 2), so it printed nothing. Replace it with a usage() that documents every option (--dir, --cabal, --package, -h/--help), the CLASSGRAPH_SO env var, the stdout/stderr split, .so discovery + re-run caveat, and examples. Unknown args now report to stderr with a '--help' hint and exit 2. Co-Authored-By: Claude Opus 4.8 (1M context) --- diff --git a/classgraph-plugin-flag.sh b/classgraph-plugin-flag.sh index 7dee35e..68f182f 100755 --- a/classgraph-plugin-flag.sh +++ b/classgraph-plugin-flag.sh @@ -33,6 +33,51 @@ set -euo pipefail cd "$(dirname "$(readlink -f "$0")")" +PROG=${0##*/} + +usage() { + cat <> cabal.project.local'). + +The plugin .so is discovered from ./dist-newstyle and the cabal store. If +more than one candidate is found you are prompted to pick one. Re-run this +script after rebuilding classgraph itself — the package id baked into the .so +path changes on each build. + +Examples: + $PROG # bare flag, dumps to ./.classgraph + $PROG --dir build/classgraph # bare flag, custom output dir + $PROG --cabal >> cabal.project.local # global stanza, appended + $PROG --cabal --package ouroboros-consensus +EOF +} + DIR=.classgraph EMIT=raw # raw | cabal PACKAGE= @@ -41,10 +86,11 @@ while [ $# -gt 0 ]; do --dir) DIR=$2; shift 2 ;; --cabal) EMIT=cabal; shift ;; --package) PACKAGE=$2; shift 2 ;; - -h|--help) - sed -n '/^#$/q;/^# /{s/^# \?//;p;}' "$0" - exit 0 ;; - *) echo "unknown argument: $1" >&2; exit 2 ;; + -h|--help) usage; exit 0 ;; + *) + echo "$PROG: unknown argument: $1" >&2 + echo "Try '$PROG --help'." >&2 + exit 2 ;; esac done