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
591
591
virtualenvwrapper
592
592
-----------------
593
593
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.
595
597
596
598
Syntax::
597
599
Original file line number Diff line number Diff line change @@ -26,4 +26,16 @@ test_virtualenvwrapper_script_set() {
26
26
" echo $VIRTUALENVWRAPPER_SCRIPT | grep -q /virtualenvwrapper.sh"
27
27
}
28
28
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
+
29
41
. " $test_dir /shunit2"
Original file line number Diff line number Diff line change @@ -1336,8 +1336,13 @@ function allvirtualenv {
1336
1336
unset IFS
1337
1337
}
1338
1338
1339
+ function _virtualenvwrapper_version {
1340
+ " $VIRTUALENVWRAPPER_PYTHON " -m ' virtualenvwrapper.hook_loader' --version
1341
+ }
1342
+
1339
1343
# :help:virtualenvwrapper: show this help message
1340
1344
function virtualenvwrapper {
1345
+ typeset version=$( _virtualenvwrapper_version)
1341
1346
cat << EOF
1342
1347
1343
1348
virtualenvwrapper is a set of extensions to Ian Bicking's virtualenv
@@ -1350,6 +1355,12 @@ For more information please refer to the documentation:
1350
1355
1351
1356
http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html
1352
1357
1358
+ Version: $version
1359
+ Script: $VIRTUALENVWRAPPER_SCRIPT
1360
+ Python: $VIRTUALENVWRAPPER_PYTHON
1361
+ WORKON_HOME: $WORKON_HOME
1362
+ PROJECT_HOME: $PROJECT_HOME
1363
+
1353
1364
Commands available:
1354
1365
1355
1366
EOF
Original file line number Diff line number Diff line change @@ -79,9 +79,20 @@ def main():
79
79
dest = 'names' ,
80
80
default = [],
81
81
)
82
+ parser .add_option (
83
+ '--version' ,
84
+ help = 'Show the version of virtualenvwrapper' ,
85
+ action = 'store_true' ,
86
+ default = False ,
87
+ )
82
88
parser .disable_interspersed_args () # stop when on option without an '-'
83
89
options , args = parser .parse_args ()
84
90
91
+ if options .version :
92
+ import importlib .metadata
93
+ print (importlib .metadata .version ('virtualenvwrapper' ))
94
+ return 0
95
+
85
96
root_logger = logging .getLogger ('virtualenvwrapper' )
86
97
87
98
# Set up logging to a file
You can’t perform that action at this time.
0 commit comments