add --version handling logic in driver.py

This commit is contained in:
Martin A. Brown 2016-05-16 09:30:18 -07:00
parent e879f2e638
commit 47b2930264
1 changed files with 9 additions and 0 deletions

View File

@ -24,6 +24,7 @@ from tldp.config import collectconfiguration
from tldp.utils import arg_isloglevel, arg_isdirectory
from tldp.utils import swapdirs, sameFilesystem
from tldp.doctypes.common import preamble, postamble
from tldp import VERSION
# -- Don't freak out with IOError when our STDOUT, handled with
# head, sed, awk, grep, etc; and, also deal with a user's ctrl-C
@ -52,6 +53,11 @@ ERR_UNKNOWNARGS = "Unknown arguments received: "
ERR_EXTRAARGS = "Extra arguments received: "
def show_version(config, *args, **kwargs):
file = kwargs.get('file', sys.stdout)
print(VERSION, file=file)
return os.EX_OK
def show_doctypes(config, *args, **kwargs):
if args:
return ERR_EXTRAARGS + ' '.join(args)
@ -508,6 +514,9 @@ def collectWorkset(config, args):
def handleArgs(config, args):
if config.version:
return show_version(config, *args)
if config.doctypes:
return show_doctypes(config, *args)