aboutsummaryrefslogtreecommitdiffstats
path: root/bsfs/apps
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2023-03-05 19:25:17 +0100
committerMatthias Baumgartner <dev@igsor.net>2023-03-05 19:25:17 +0100
commite4845c627e97a6d125bf33d9e7a4a8d373d7fc4a (patch)
tree634198c34aae3c0306ce30ac7452abd7b53a14e8 /bsfs/apps
parent9b490d19dcebc0fc24cb2ab89a783f1f7d6147f7 (diff)
parent3ae93a405724ca6b5ddeb0b458fcc95685f83f09 (diff)
downloadbsfs-e4845c627e97a6d125bf33d9e7a4a8d373d7fc4a.tar.gz
bsfs-e4845c627e97a6d125bf33d9e7a4a8d373d7fc4a.tar.bz2
bsfs-e4845c627e97a6d125bf33d9e7a4a8d373d7fc4a.zip
Merge branch 'mb/diogenes' into develop
Diffstat (limited to 'bsfs/apps')
-rw-r--r--bsfs/apps/__init__.py43
-rw-r--r--bsfs/apps/init.py11
-rw-r--r--bsfs/apps/migrate.py6
3 files changed, 43 insertions, 17 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 ##
diff --git a/bsfs/apps/init.py b/bsfs/apps/init.py
index 3e2ef37..9afbdd5 100644
--- a/bsfs/apps/init.py
+++ b/bsfs/apps/init.py
@@ -1,9 +1,5 @@
-"""
+#!/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 json
@@ -60,9 +56,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..34ea2e7 100644
--- a/bsfs/apps/migrate.py
+++ b/bsfs/apps/migrate.py
@@ -1,9 +1,5 @@
-"""
+#!/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 json