Pyvider CLI Tool.
When run by Terraform (detected via PLUGIN_MAGIC_COOKIE environment variable),
this will automatically default to the 'provide' command.
Source code in pyvider/cli/main.py
| @click.group(invoke_without_command=True)
@flexible_options # Add logging and config options at root level
@output_options # Add output format options
@click.pass_context
def cli(ctx: click.Context, /, **kwargs: Any) -> None:
"""
Pyvider CLI Tool.
When run by Terraform (detected via PLUGIN_MAGIC_COOKIE environment variable),
this will automatically default to the 'provide' command.
"""
# Ensure the custom context object is created and attached
# at the top level of the application. This makes it available to all
# subcommands via `ctx.obj`.
if ctx.obj is None:
ctx.obj = PyviderContext()
# Store the CLI options in the context for subcommands to access
for key, value in kwargs.items():
if value is not None:
setattr(ctx.obj, key, value)
if ctx.invoked_subcommand is None:
# Default behavior: When called with no subcommand, run as provider server
# (This is the normal mode when Terraform calls the plugin)
provide_command = cli.get_command(ctx, "provide")
if provide_command:
ctx.invoke(provide_command)
else:
# This case should not happen if the CLI is assembled correctly
perr("Error: Default command 'provide' not found.")
pout(cli.get_help(ctx))
|