File tree Expand file tree Collapse file tree 4 files changed +37
-1
lines changed
Expand file tree Collapse file tree 4 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -591,7 +591,9 @@ Other Commands
591591virtualenvwrapper
592592-----------------
593593
594- Print a list of commands and their descriptions as basic help output.
594+ Print a list of commands, their descriptions, and some details about
595+ the version and locations used by virtualenvwrapper as basic help
596+ output.
595597
596598Syntax::
597599
Original file line number Diff line number Diff line change @@ -26,4 +26,16 @@ test_virtualenvwrapper_script_set() {
2626 " echo $VIRTUALENVWRAPPER_SCRIPT | grep -q /virtualenvwrapper.sh"
2727}
2828
29+ test_virtualenvwrapper_version () {
30+ source " $test_dir /../virtualenvwrapper.sh"
31+ typeset ver=$( _virtualenvwrapper_version)
32+ assertTrue " version is empty" " [ -n $ver ]"
33+ }
34+
35+ test_virtualenvwrapper_help_shows_version () {
36+ source " $test_dir /../virtualenvwrapper.sh"
37+ typeset pattern=" Version: $( _virtualenvwrapper_version) "
38+ assertTrue " version not in command output" " virtualenvwrapper | grep \" $pattern \" "
39+ }
40+
2941. " $test_dir /shunit2"
Original file line number Diff line number Diff line change @@ -1336,8 +1336,13 @@ function allvirtualenv {
13361336 unset IFS
13371337}
13381338
1339+ function _virtualenvwrapper_version {
1340+ " $VIRTUALENVWRAPPER_PYTHON " -m ' virtualenvwrapper.hook_loader' --version
1341+ }
1342+
13391343# :help:virtualenvwrapper: show this help message
13401344function virtualenvwrapper {
1345+ typeset version=$( _virtualenvwrapper_version)
13411346 cat << EOF
13421347
13431348virtualenvwrapper is a set of extensions to Ian Bicking's virtualenv
@@ -1350,6 +1355,12 @@ For more information please refer to the documentation:
13501355
13511356 http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html
13521357
1358+ Version: $version
1359+ Script: $VIRTUALENVWRAPPER_SCRIPT
1360+ Python: $VIRTUALENVWRAPPER_PYTHON
1361+ WORKON_HOME: $WORKON_HOME
1362+ PROJECT_HOME: $PROJECT_HOME
1363+
13531364Commands available:
13541365
13551366EOF
Original file line number Diff line number Diff line change @@ -79,9 +79,20 @@ def main():
7979 dest = 'names' ,
8080 default = [],
8181 )
82+ parser .add_option (
83+ '--version' ,
84+ help = 'Show the version of virtualenvwrapper' ,
85+ action = 'store_true' ,
86+ default = False ,
87+ )
8288 parser .disable_interspersed_args () # stop when on option without an '-'
8389 options , args = parser .parse_args ()
8490
91+ if options .version :
92+ import importlib .metadata
93+ print (importlib .metadata .version ('virtualenvwrapper' ))
94+ return 0
95+
8596 root_logger = logging .getLogger ('virtualenvwrapper' )
8697
8798 # Set up logging to a file
You can’t perform that action at this time.
0 commit comments