Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask: what happened to the script_info_option?

Tags:

flask

I wanted it to add common app-configuration options such as --config, --loglevel, --logfile, etc. to my flask.cli group and read them from the scriptinfo in my app factory function.

The @script_info_option decorator was apparently removed after 0.11 with a cryptic commit message like "implementing simplified interface".

So... how do I do add app-factory-time configuration options now?

like image 901
Matt Chaput Avatar asked Dec 04 '25 09:12

Matt Chaput


1 Answers

Found out how you do it now:

  1. Decorate your app factory with @click.pass_context so it gets the context as the first argument.
  2. In the app factory, use ctx.find_root().params to get what was passed to the group.
like image 122
Matt Chaput Avatar answered Dec 08 '25 00:12

Matt Chaput



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!