learn -V CLI option

Help users to get the versions while reporting bugs.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2016-06-07 00:36:57 +02:00
parent 19ac578a50
commit a41fecd057
2 changed files with 16 additions and 5 deletions

View File

@ -2,7 +2,7 @@
### General informations ### General informations
- OfflineIMAP version: - OfflineIMAP version (including imaplib2 if available: `offlineimap -V`):
- server name or domain: - server name or domain:
- CLI options: - CLI options:

View File

@ -79,10 +79,11 @@ class OfflineImap(object):
return self.__sync(options) return self.__sync(options)
def __parse_cmd_options(self): def __parse_cmd_options(self):
parser = OptionParser(version=offlineimap.__version__, parser = OptionParser(
description="%s.\n\n%s" % version=offlineimap.__version__,
(offlineimap.__copyright__, description="%s.\n\n%s"% (offlineimap.__copyright__,
offlineimap.__license__)) offlineimap.__license__)
)
parser.add_option("--dry-run", parser.add_option("--dry-run",
action="store_true", dest="dryrun", action="store_true", dest="dryrun",
default=False, default=False,
@ -149,9 +150,19 @@ class OfflineImap(object):
action="store_true", dest="migrate_fmd5", default=False, action="store_true", dest="migrate_fmd5", default=False,
help="migrate FMD5 hashes from versions prior to 6.3.5") help="migrate FMD5 hashes from versions prior to 6.3.5")
parser.add_option("-V",
action="store_true", dest="version",
default=False,
help="show full version infos")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
globals.set_options (options) globals.set_options (options)
if options.version:
print("offlineimap v%s, imaplib2 v%s (%s)"% (
offlineimap.__version__, imaplib.__version__, imaplib.DESC))
sys.exit(0)
# Read in configuration file. # Read in configuration file.
if not options.configfile: if not options.configfile:
# Try XDG location, then fall back to ~/.offlineimaprc # Try XDG location, then fall back to ~/.offlineimaprc