Skip to content

Commit 7c7543f

Browse files
committed
Add smart case file detection to mfc wrapper
- Users can now run 'mfc case.py' instead of 'mfc run case.py' - Wrapper auto-detects .py files or existing files and prepends 'run' - Both forms work: 'mfc case.py' and 'mfc run case.py' - Updated help text and caveats to show both usage styles - Improved UX for the primary use case while maintaining explicit syntax
1 parent cb29fc5 commit 7c7543f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

packaging/homebrew/mfc.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ def install
102102
MFC (Homebrew) #{version}
103103
104104
Usage:
105+
mfc <case.py> [options]
105106
mfc run <case.py> [options]
106107
107108
Examples:
108-
mfc run case.py -j 1
109+
mfc case.py -n 2
110+
mfc run case.py -n 2 -t pre_process simulation
109111
110112
Notes:
111113
- This Homebrew wrapper uses prebuilt binaries and a preinstalled venv.
@@ -115,9 +117,15 @@ def install
115117
exit 0
116118
fi
117119
120+
# Smart detection: if first arg looks like a case file, auto-prepend "run"
121+
if [[ "${SUBCMD}" =~ \.py$ ]] || [[ -f "${SUBCMD}" ]]; then
122+
ARGS=("run" "${ARGS[@]}")
123+
SUBCMD="run"
124+
fi
125+
118126
if [[ "${SUBCMD}" != "run" ]]; then
119127
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."
128+
echo "Use 'mfc <case.py>' or clone the repository for developer commands."
121129
exit 2
122130
fi
123131
@@ -218,17 +226,18 @@ def caveats
218226
MFC has been installed successfully!
219227
220228
To run a case:
221-
mfc run <case.py>
229+
mfc <case.py>
230+
mfc run <case.py> (explicit form)
222231
223232
Pre-built binaries are also available directly:
224233
pre_process, simulation, post_process
225234
226235
Examples are available in:
227236
#{prefix}/examples
228237
229-
Example:
238+
Quick start:
230239
cp #{prefix}/examples/1D_sodshocktube/case.py .
231-
mfc run case.py
240+
mfc case.py -n 2
232241
233242
Note: Cantera 3.1.0 is pre-installed in the MFC virtual environment.
234243
EOS

0 commit comments

Comments
 (0)