merged command line and gui app in one command

This commit is contained in:
Thomas Peetz
2025-01-14 13:10:24 +01:00
parent f74c07af9a
commit 276302570f
69 changed files with 589 additions and 183 deletions
+32
View File
@@ -0,0 +1,32 @@
from cement import Controller, ex
from ..database import KontorDB
class Database(Controller):
class Meta:
label = 'database'
stacked_type = 'nested'
stacked_on = 'base'
@ex(
help='export database to given file',
arguments=[
(['-f', '--file'],
{'help': 'file to store database content',
'action': 'store',
'dest': 'db_file'})
],
)
def export(self):
data = {
'db_file': 'data.json',
'export_type': 'JSON',
}
if self.app.pargs.db_file is not None:
data['db_file'] = self.app.pargs.db_file
kontor_db = KontorDB(self.app.session, self.app.log)
table_list = kontor_db.get_table_names()
kontor_db.export_db(data['export_type'], data['db_file'], table_list)
self.app.render(data, 'command1.jinja2')