Skip to content

Commit c73b091

Browse files
committed
Improve Homebrew wrapper UX: add help, block unsupported commands, fix ARGS crash
1 parent b1e3ac5 commit c73b091

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

packaging/homebrew/mfc.rb

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def install
8484
ORIG_DIR="$(pwd)"
8585
8686
# Process arguments and convert relative paths to absolute paths
87-
ARGS=()
87+
declare -a ARGS=()
8888
for arg in "$@"; do
8989
# If argument looks like a file path and exists as relative path
9090
if [[ "$arg" =~ \\.(py|txt|json|yaml|yml)$ ]] && [ -e "${ORIG_DIR}/${arg}" ]; then
@@ -94,6 +94,33 @@ def install
9494
fi
9595
done
9696
97+
SUBCMD="${ARGS[0]-}"
98+
99+
# Friendly help and guardrails
100+
if [[ ${#ARGS[@]} -eq 0 ]] || [[ "${SUBCMD}" == "--help" ]] || [[ "${SUBCMD}" == "-h" ]]; then
101+
cat <<'HHELP'
102+
MFC (Homebrew) #{version}
103+
104+
Usage:
105+
mfc run <case.py> [options]
106+
107+
Examples:
108+
mfc run case.py -j 1
109+
110+
Notes:
111+
- This Homebrew wrapper uses prebuilt binaries and a preinstalled venv.
112+
- Developer commands (build, clean, test, etc.) are not available here.
113+
Clone the MFC repo for the full developer workflow.
114+
HHELP
115+
exit 0
116+
fi
117+
118+
if [[ "${SUBCMD}" != "run" ]]; then
119+
echo "mfc (Homebrew): only 'run' is supported in the Homebrew package."
120+
echo "Use 'mfc run <case.py>' or clone the repository for developer commands."
121+
exit 2
122+
fi
123+
97124
# Create a temporary working directory (Cellar is read-only)
98125
TMPDIR="$(mktemp -d)"
99126
trap 'rm -rf "${TMPDIR}"' EXIT
@@ -172,12 +199,8 @@ def _homebrew_is_buildable(self):
172199
# Set PYTHONPATH to include current directory so sitecustomize.py is found
173200
export PYTHONPATH="${TMPDIR}:#{prefix}/toolchain:${PYTHONPATH:-}"
174201
175-
# For 'mfc run', add --no-build flag to skip compilation
176-
if [ "${1-}" = "run" ]; then
177-
exec ./mfc.sh "${ARGS[@]}" --no-build
178-
else
179-
exec ./mfc.sh "${ARGS[@]}"
180-
fi
202+
# Always run with --no-build in Homebrew package
203+
exec ./mfc.sh "${ARGS[@]}" --no-build
181204
EOS
182205
(libexec/"mfc").chmod 0755
183206

0 commit comments

Comments
 (0)