|
| 1 | +import sys |
| 2 | + |
1 | 3 | from click import command, argument, option |
2 | 4 | import cloudinary.provisioning |
3 | 5 |
|
4 | 6 | from cloudinary_cli.utils.api_utils import handle_api_command |
| 7 | +from cloudinary_cli.utils.env_config import env_config_error |
5 | 8 |
|
6 | 9 |
|
7 | 10 | @command("provisioning", |
|
12 | 15 | \te.g. cld provisioning sub_accounts |
13 | 16 | """) |
14 | 17 | @argument("params", nargs=-1) |
15 | | -@option("-o", "--optional_parameter", multiple=True, nargs=2, help="Pass optional parameters as raw strings.") |
| 18 | +@option("-o", "--optional_parameter", multiple=True, nargs=2, |
| 19 | + help="Pass an optional parameter as a string, with no parsing. e.g. -o prefix demo") |
16 | 20 | @option("-O", "--optional_parameter_parsed", multiple=True, nargs=2, |
17 | | - help="Pass optional parameters as interpreted strings.") |
| 21 | + help="Pass an optional parameter and parse its value as JSON or a boolean. e.g. -O enabled true") |
18 | 22 | @option("-ls", "--ls", is_flag=True, help="List all available methods in the Provisioning API.") |
19 | 23 | @option("--save", nargs=1, help="Save output to a file.") |
20 | 24 | @option("-d", "--doc", is_flag=True, help="Open the Provisioning API reference in a browser.") |
21 | 25 | def provisioning(params, optional_parameter, optional_parameter_parsed, ls, save, doc): |
| 26 | + # -c, -C and the saved default do not replace CLOUDINARY_ACCOUNT_URL, so an invalid one is always an error here. |
| 27 | + account_url_error = env_config_error("CLOUDINARY_ACCOUNT_URL") |
| 28 | + if account_url_error: |
| 29 | + sys.exit(account_url_error) |
| 30 | + |
22 | 31 | return handle_api_command(params, optional_parameter, optional_parameter_parsed, ls, save, doc, |
23 | 32 | doc_url="https://cloudinary.com/documentation/provisioning_api", |
24 | 33 | api_instance=cloudinary.provisioning, |
|
0 commit comments