Add the --spec arg for rattail run-dashapp cmd

This commit is contained in:
Lance Edgar 2021-12-20 19:23:16 -06:00
parent 7aef6b5923
commit e6be11d54e

View file

@ -36,10 +36,15 @@ class RunDashApp(commands.Subcommand):
name = 'run-dashapp'
description = __doc__.strip()
def run(self, args):
def add_parser_args(self, parser):
parser.add_argument('--spec', default='rattail_dash.dashapp.sample:sample_dash_app',
help="The \"spec\" string for the Dash app to run. "
"This will normally be a factory function as opposed "
"to an app class. If you do not specify this, the "
"default sample app will run, spec for which is: "
"rattail_dash.dashapp.sample:sample_dash_app")
# TODO: let command line or config determine which app to run;
# also whether it should run in debug mode etc.
from rattail_dash.dashapp.sample import sample_dash_app
dashapp = sample_dash_app(self.config)
def run(self, args):
factory = self.app.load_object(args.spec)
dashapp = factory(self.config)
dashapp.run_server(debug=True)