Skip to content

Commit 6cc7b72

Browse files
committed
Handle multiple options in configure #33
Signed-off-by: Jono Yang <[email protected]>
1 parent 45e4a2a commit 6cc7b72

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Replace \<version\> with the version number of the Python being used.
8181
To generate requirements-dev.txt after requirements.txt has been generated:
8282

8383
.. code-block:: bash
84-
./configure --dev
84+
./configure --init --dev
8585
source venv/bin/activate
8686
python etc/scripts/gen_requirements_dev.py -s venv/lib/python<version>/site-packages/
8787

configure

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,18 @@ CFG_DEV_MODE=0
164164
CFG_REQUIREMENTS=$REQUIREMENTS
165165
NO_INDEX="--no-index"
166166

167-
case "$CLI_ARGS" in
168-
--help) cli_help;;
169-
--clean) clean;;
170-
--dev) CFG_REQUIREMENTS="$DEV_REQUIREMENTS" && CFG_DEV_MODE=1;;
171-
--init) NO_INDEX="";;
172-
esac
167+
# We are using getopts to parse option arguments that start with "-"
168+
while getopts :-: optchar; do
169+
case "${optchar}" in
170+
-)
171+
case "${OPTARG}" in
172+
help ) cli_help;;
173+
clean ) clean;;
174+
dev ) CFG_REQUIREMENTS="$DEV_REQUIREMENTS" && CFG_DEV_MODE=1;;
175+
init ) NO_INDEX="";;
176+
esac;;
177+
esac
178+
done
173179

174180
PIP_EXTRA_ARGS="$PIP_EXTRA_ARGS $NO_INDEX"
175181

configure.bat

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,24 @@ set CFG_DEV_MODE=0
6666
set "CFG_REQUIREMENTS=%REQUIREMENTS%"
6767
set "NO_INDEX=--no-index"
6868

69-
if "%1" EQU "--help" (goto cli_help)
70-
if "%1" EQU "--clean" (goto clean)
71-
if "%1" EQU "--dev" (
72-
set "CFG_REQUIREMENTS=%DEV_REQUIREMENTS%"
73-
set CFG_DEV_MODE=1
74-
)
75-
if "%1" EQU "--init" (
76-
set "NO_INDEX= "
77-
)
78-
if "%1" EQU "--python" (
79-
echo "The --python option is now DEPRECATED. Use the PYTHON_EXECUTABLE environment"
80-
echo "variable instead. Run configure --help for details."
81-
exit /b 0
69+
:again
70+
if not "%1" == "" (
71+
if "%1" EQU "--help" (goto cli_help)
72+
if "%1" EQU "--clean" (goto clean)
73+
if "%1" EQU "--dev" (
74+
set "CFG_REQUIREMENTS=%DEV_REQUIREMENTS%"
75+
set CFG_DEV_MODE=1
76+
)
77+
if "%1" EQU "--init" (
78+
set "NO_INDEX= "
79+
)
80+
if "%1" EQU "--python" (
81+
echo "The --python option is now DEPRECATED. Use the PYTHON_EXECUTABLE environment"
82+
echo "variable instead. Run configure --help for details."
83+
exit /b 0
84+
)
85+
shift
86+
goto again
8287
)
8388

8489
set "PIP_EXTRA_ARGS=%PIP_EXTRA_ARGS% %NO_INDEX%"

0 commit comments

Comments
 (0)