mirror of https://github.com/tLDP/python-tldp
add --version handling logic in driver.py
This commit is contained in:
parent
e879f2e638
commit
47b2930264
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue