smurfix/flask-script

Make available commands configurable

italomaia opened this issue · 1 comments

Today, I was trying to handle configurable extensions commands availability. That is, I want to be able to add commands to my manager based on the available extensions configured with my application.

The thing is, I only know which commands are to be loaded after my Flask instance was created. If it was possible to have the Flask instance created before processing commands, I could load the "dynamic" commands, per extension, with easy.

yv commented

This is easy as long as you don't use a decorator. I.e. instead of

@manager.command
def do_thing(parameter)

you declare the function in one place and when you're ready, do a

if ('something' in app):
   manager.command(do_thing)