diff options
author | Matthias Baumgartner <dev@igsor.net> | 2023-03-01 12:49:47 +0100 |
---|---|---|
committer | Matthias Baumgartner <dev@igsor.net> | 2023-03-01 12:49:47 +0100 |
commit | d822df3dad0525f35dbacda9d5a66f4756f079ff (patch) | |
tree | 1387c5a7e8fd669c11f61d04a4ab71607867ecf8 /bsfs | |
parent | f9eec185bf3d857c220e5d78de75ec6713437330 (diff) | |
download | bsfs-d822df3dad0525f35dbacda9d5a66f4756f079ff.tar.gz bsfs-d822df3dad0525f35dbacda9d5a66f4756f079ff.tar.bz2 bsfs-d822df3dad0525f35dbacda9d5a66f4756f079ff.zip |
Integrate main app into package
Diffstat (limited to 'bsfs')
-rw-r--r-- | bsfs/apps/__init__.py | 38 | ||||
-rw-r--r-- | bsfs/apps/init.py | 6 | ||||
-rw-r--r-- | bsfs/apps/migrate.py | 1 |
3 files changed, 43 insertions, 2 deletions
diff --git a/bsfs/apps/__init__.py b/bsfs/apps/__init__.py index 7efaa87..3dec9ad 100644 --- a/bsfs/apps/__init__.py +++ b/bsfs/apps/__init__.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 """ Part of the BlackStar filesystem (bsfs) module. @@ -5,16 +6,53 @@ 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)) + # 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 ## diff --git a/bsfs/apps/init.py b/bsfs/apps/init.py index 3e2ef37..ec48525 100644 --- a/bsfs/apps/init.py +++ b/bsfs/apps/init.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 """ Part of the BlackStar filesystem (bsfs) module. @@ -60,9 +61,10 @@ def main(argv): # print config if args.output is not None: with open(args.output, mode='wt', encoding='UTF-8') as ofile: - json.dump(config, ofile) + json.dump(config, ofile, indent=4) else: - json.dump(config, sys.stdout) + json.dump(config, sys.stdout, indent=4) + print('') ## main ## diff --git a/bsfs/apps/migrate.py b/bsfs/apps/migrate.py index b9d019f..cb62542 100644 --- a/bsfs/apps/migrate.py +++ b/bsfs/apps/migrate.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 """ Part of the BlackStar filesystem (bsfs) module. |