aboutsummaryrefslogtreecommitdiffstats
path: root/bsfs/apps/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'bsfs/apps/__init__.py')
-rw-r--r--bsfs/apps/__init__.py43
1 files changed, 38 insertions, 5 deletions
diff --git a/bsfs/apps/__init__.py b/bsfs/apps/__init__.py
index 7efaa87..62dc5b5 100644
--- a/bsfs/apps/__init__.py
+++ b/bsfs/apps/__init__.py
@@ -1,20 +1,53 @@
-"""
+#!/usr/bin/env python3
-Part of the BlackStar filesystem (bsfs) module.
-A copy of the license is provided with the project.
-Author: Matthias Baumgartner, 2022
-"""
# imports
+import argparse
import typing
+# bsfs imports
+import bsfs
+
# inner-module imports
from .init import main as init
from .migrate import main as migrate
# exports
__all__: typing.Sequence[str] = (
+ 'main',
'init',
'migrate',
)
+# config
+apps = {
+ 'init' : init,
+ 'migrate' : migrate,
+ }
+
+
+## code ##
+
+def main(argv=None):
+ """Black Star File System maintenance tools."""
+ parser = argparse.ArgumentParser(description=main.__doc__, prog='bsfs')
+ # version
+ parser.add_argument('--version', action='version',
+ version='%(prog)s version {}.{}.{}'.format(*bsfs.version_info)) # pylint: disable=C0209
+ # application selection
+ parser.add_argument('app', choices=apps.keys(),
+ help='Select the application to run.')
+ # dangling args
+ parser.add_argument('rest', nargs=argparse.REMAINDER)
+ # parse
+ args = parser.parse_args(argv)
+ # run application
+ apps[args.app](args.rest)
+
+
+## main ##
+
+if __name__ == '__main__':
+ import sys
+ main(sys.argv[1:])
+
## EOF ##