Commits

Doug Hellmann committed f4372e0 Merge

Merged in claymcclure/virtualenvwrapper (pull request #2)

Add `mkproject --force` option

  • Participants
  • Parent commits 6031a9c, dcd6aa4

Comments (0)

Files changed (4)

File docs/source/command_ref.rst

 
 Syntax::
 
-    mkproject [-t template] [virtualenv_options] ENVNAME
+    mkproject [-f|--force] [-t template] [virtualenv_options] ENVNAME
+
+-f, --force    Create the virtualenv even if the project directory
+               already exists
 
 The template option may be repeated to have several templates used to
 create a new project.  The templates are applied in the order named on

File docs/source/developers.rst

 
 - Sphinx
 - docutils
+- sphinxcontrib-bitbucket
 
 Once all of the tools are installed into a virtualenv using
 pip, run ``make html`` to generate the HTML version of the

File tests/test_project_mk.sh

     mkproject myproject4 >/dev/null 2>&1
     output=`mkproject myproject4 2>&1`
     assertTrue "Did not see expected message 'already exists' in: $output" "echo $output | grep 'already exists'"
+    output=`mkproject -f myproject4 2>&1`
+    assertFalse "Saw unexpected message 'already exists' in: $output" "echo $output | grep 'already exists'"
 }
 
 test_same_workon_and_project_home () {

File virtualenvwrapper.sh

 
 # Show help for mkproject
 function virtualenvwrapper_mkproject_help {
-    echo "Usage: mkproject [-t template] [virtualenv options] project_name"
-    echo ""
+    echo "Usage: mkproject [-f|--force] [-t template] [virtualenv options] project_name"
+    echo
+    echo "-f, --force    Create the virtualenv even if the project directory"
+    echo "               already exists"
+    echo
     echo "Multiple templates may be selected.  They are applied in the order"
     echo "specified on the command line."
-    echo;
+    echo
     echo "mkvirtualenv help:"
     echo
-    mkvirtualenv -h;
+    mkvirtualenv -h
     echo
     echo "Available project templates:"
     echo
     typeset tst
     typeset a
     typeset t
+    typeset force
     typeset templates
 
     in_args=( "$@" )
+    force=0
 
     if [ -n "$ZSH_VERSION" ]
     then
             -h|--help)
                 virtualenvwrapper_mkproject_help;
                 return;;
+            -f|--force)
+                force=1;;
             -t)
                 i=$(( $i + 1 ));
                 templates="$templates ${in_args[$i]}";;
     eval "typeset envname=\$$#"
     virtualenvwrapper_verify_project_home || return 1
 
-    if [ -d "$PROJECT_HOME/$envname" ]
+    if [ -d "$PROJECT_HOME/$envname" -a $force -eq 0 ]
     then
         echo "Project $envname already exists." >&2
         return 1