diff options
-rwxr-xr-x[-rw-r--r--] | tagit.app | 45 | ||||
-rw-r--r-- | tagit/apps/__init__.py | 43 |
2 files changed, 47 insertions, 41 deletions
diff --git a/tagit.app b/tagit.app index e18bbc0..42a35a0 100644..100755 --- a/tagit.app +++ b/tagit.app @@ -1,42 +1,7 @@ -#!/usr/bin/python3.6 -"""The tagit application. - -Part of the tagit module. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" -# imports -import argparse -import sys - -# module imports -import tagit -import tagit.apps - -# config -apps = { - 'desktop' : tagit.apps.desktop, - } - - -## code ## - +#!/usr/bin/env python3 if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Image tagger tool.', prog='tagit') - # version - parser.add_argument('--version', action='version', - version='%(prog)s {}.{}.{}'.format(*tuple(tagit.version_info))) - # application selection - parser.add_argument('app', choices=apps.keys(), nargs='?', default='desktop', - help='Select the application to run.') - # dangling args - parser.add_argument('rest', nargs=argparse.REMAINDER) - # parse - args = parser.parse_args() - # run application - try: - apps[args.app](args.rest) - except Exception as e: - print(str(e)) - + import tagit.apps + import sys + tagit.apps.main(sys.argv[1:]) + ## EOF ## diff --git a/tagit/apps/__init__.py b/tagit/apps/__init__.py index 4c64128..6b4986c 100644 --- a/tagit/apps/__init__.py +++ b/tagit/apps/__init__.py @@ -1,10 +1,51 @@ -""" +#!/usr/bin/env python3 +"""The tagit applications. Part of the tagit module. A copy of the license is provided with the project. Author: Matthias Baumgartner, 2022 """ +# standard imports +import argparse +import typing + +# tagit imports +import tagit + # inner-module imports from .desktop import main as desktop +# exports +__all__: typing.Sequence[str] = ( + 'desktop', + ) + +# config +apps = { + 'desktop' : desktop, + } + + +## code ## + +def main(argv=None): + """The BSFS browser, focused on image tagging.""" + parser = argparse.ArgumentParser(description=main.__doc__, prog='tagit') + # version + parser.add_argument('--version', action='version', + version='%(prog)s {}.{}.{}'.format(*tuple(tagit.version_info))) # pylint: disable=C0209 + # application selection + parser.add_argument('app', choices=apps.keys(), nargs='?', default='desktop', + help='Select the application to run.') + # dangling args + parser.add_argument('rest', nargs=argparse.REMAINDER) + # parse + args = parser.parse_args() + # run application + apps[args.app](args.rest) + +if __name__ == '__main__': + import sys + main(sys.argv[1:]) + ## EOF ## |