如何获取所有可用的命令选项来设置环境变量? [英] How to get all available Command Options to set environment variables?

查看:68
本文介绍了如何获取所有可用的命令选项来设置环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于设置命令选项的烧瓶手册讨论有关命令 FLASK_RUN_PORT 来设置可由 Click 加载的环境变量.

The flask manual about Setting Command Options only talks about the command FLASK_RUN_PORT to set environment variables that can be loaded by Click.

如何找到其他选项并将其与 FLASK_COMMAND_OPTION 模式一起使用?

How can i find the other options and use them with the pattern FLASK_COMMAND_OPTION ?

我想将其设置为我的vscode launch.json.

I want to set it to my vscode launch.json.

推荐答案

您可以通过在shell中执行来访问所有可用命令:

You can access all available commands by executing in a shell :

flask --help

[...]
Commands:
      db     Perform database migrations.
      run    Runs a development server.
      shell  Runs a shell in the app context.

然后,如果要列出给定命令的所有可用选项,例如 run :

Then if you want to list all available options for a given command like run:

flask run --help 

Options:
      -h, --host TEXT                 The interface to bind to.
      -p, --port INTEGER              The port to bind to.
      --reload / --no-reload          Enable or disable the reloader.  By default
                                      the reloader is active if debug is enabled.
      --debugger / --no-debugger      Enable or disable the debugger.  By default
                                      the debugger is active if debug is enabled.
      --eager-loading / --lazy-loader
                                      Enable or disable eager loading.  By default
                                      eager loading is enabled if the reloader is
                                      disabled.
      --with-threads / --without-threads
                                      Enable or disable multithreading.
      --help                          Show this message and exit.

因此,您可以将它们与doc示例中的模式一起使用,只需在ALLCAPS中将名称和选项与下划线连接起来即可.

So you can use them with the pattern like in the doc examples, you just have to concatenate the name and the options with underscores, in ALLCAPS:

export FLASK_RUN_PORT=8000
export FLASK_RUN_HOST=0.0.0.0

您还可以定义布尔选项:

You can also define boolean options :

export FLASK_RUN_RELOAD=True   
export FLASK_RUN_RELOAD=False

注意: flask --help 将列出默认命令,但是如果您在执行此帮助之前定义了您的应用程序( export FLASK_APP = my_app.py ),您还将获取所有自定义命令.

NOTE : flask --help will list default commands, but if you define your app before executing this help (export FLASK_APP=my_app.py), you will also get all custom commands.

Commands:
      db      Perform database migrations.
      deploy
      run     Runs a development server.
      shell   Runs a shell in the app context.
      test    perform tests

这篇关于如何获取所有可用的命令选项来设置环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆