Skip to content

Commit f4372e0

Browse files
committed
Merged in claymcclure/virtualenvwrapper (pull request #2)
Add `mkproject --force` option
2 parents 6031a9c + dcd6aa4 commit f4372e0

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

docs/source/command_ref.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,10 @@ PROJECT_HOME.
489489

490490
Syntax::
491491

492-
mkproject [-t template] [virtualenv_options] ENVNAME
492+
mkproject [-f|--force] [-t template] [virtualenv_options] ENVNAME
493+
494+
-f, --force Create the virtualenv even if the project directory
495+
already exists
493496

494497
The template option may be repeated to have several templates used to
495498
create a new project. The templates are applied in the order named on

docs/source/developers.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ docs:
2424

2525
- Sphinx
2626
- docutils
27+
- sphinxcontrib-bitbucket
2728

2829
Once all of the tools are installed into a virtualenv using
2930
pip, run ``make html`` to generate the HTML version of the

tests/test_project_mk.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ test_project_exists () {
6666
mkproject myproject4 >/dev/null 2>&1
6767
output=`mkproject myproject4 2>&1`
6868
assertTrue "Did not see expected message 'already exists' in: $output" "echo $output | grep 'already exists'"
69+
output=`mkproject -f myproject4 2>&1`
70+
assertFalse "Saw unexpected message 'already exists' in: $output" "echo $output | grep 'already exists'"
6971
}
7072

7173
test_same_workon_and_project_home () {

virtualenvwrapper.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -974,14 +974,17 @@ function setvirtualenvproject {
974974

975975
# Show help for mkproject
976976
function virtualenvwrapper_mkproject_help {
977-
echo "Usage: mkproject [-t template] [virtualenv options] project_name"
978-
echo ""
977+
echo "Usage: mkproject [-f|--force] [-t template] [virtualenv options] project_name"
978+
echo
979+
echo "-f, --force Create the virtualenv even if the project directory"
980+
echo " already exists"
981+
echo
979982
echo "Multiple templates may be selected. They are applied in the order"
980983
echo "specified on the command line."
981-
echo;
984+
echo
982985
echo "mkvirtualenv help:"
983986
echo
984-
mkvirtualenv -h;
987+
mkvirtualenv -h
985988
echo
986989
echo "Available project templates:"
987990
echo
@@ -996,9 +999,11 @@ function mkproject {
996999
typeset tst
9971000
typeset a
9981001
typeset t
1002+
typeset force
9991003
typeset templates
10001004

10011005
in_args=( "$@" )
1006+
force=0
10021007

10031008
if [ -n "$ZSH_VERSION" ]
10041009
then
@@ -1015,6 +1020,8 @@ function mkproject {
10151020
-h|--help)
10161021
virtualenvwrapper_mkproject_help;
10171022
return;;
1023+
-f|--force)
1024+
force=1;;
10181025
-t)
10191026
i=$(( $i + 1 ));
10201027
templates="$templates ${in_args[$i]}";;
@@ -1038,7 +1045,7 @@ function mkproject {
10381045
eval "typeset envname=\$$#"
10391046
virtualenvwrapper_verify_project_home || return 1
10401047

1041-
if [ -d "$PROJECT_HOME/$envname" ]
1048+
if [ -d "$PROJECT_HOME/$envname" -a $force -eq 0 ]
10421049
then
10431050
echo "Project $envname already exists." >&2
10441051
return 1

0 commit comments

Comments
 (0)