Skip to content

Commit 41706e1

Browse files
committed
Improve wrapper validation and error messages
Address qodo-merge-pro feedback: - Add --version/-v flag handling to show version at wrapper level - Validate that first non-flag argument is a Python case file - Provide clearer error messages for common mistakes: * Missing case file * Invalid case file (not .py or doesn't exist) * Using 'mfc run' syntax This prevents confusing errors from being passed to the underlying mfc.sh and gives users immediate, actionable feedback.
1 parent 76ac76e commit 41706e1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

packaging/homebrew/mfc.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ def install
114114
exit 0
115115
fi
116116
117+
# Handle --version flag
118+
if [[ "${ARGS[0]-}" == "--version" ]] || [[ "${ARGS[0]-}" == "-v" ]]; then
119+
echo "MFC (Homebrew) #{version}"
120+
exit 0
121+
fi
122+
117123
# Check if user accidentally used 'mfc run' syntax
118124
if [[ "${ARGS[0]}" == "run" ]]; then
119125
echo "mfc (Homebrew): The 'run' command is not needed."
@@ -122,6 +128,29 @@ def install
122128
exit 2
123129
fi
124130
131+
# Validate that first non-flag argument is a Python case file
132+
first_nonflag=""
133+
for arg in "${ARGS[@]}"; do
134+
if [[ "$arg" != -* ]]; then
135+
first_nonflag="$arg"
136+
break
137+
fi
138+
done
139+
140+
if [[ -z "${first_nonflag}" ]]; then
141+
echo "mfc (Homebrew): missing case file."
142+
echo "Usage: mfc <case.py> [options]"
143+
echo "Example: mfc case.py -n 2"
144+
exit 2
145+
fi
146+
147+
if [[ ! "${first_nonflag}" =~ \.py$ ]] && [[ ! -f "${first_nonflag}" ]]; then
148+
echo "mfc (Homebrew): first argument must be a Python case file."
149+
echo "Given: ${first_nonflag}"
150+
echo "Usage: mfc <case.py> [options]"
151+
exit 2
152+
fi
153+
125154
# Always prepend "run" since this wrapper only supports running cases
126155
ARGS=("run" "${ARGS[@]}")
127156

0 commit comments

Comments
 (0)