new_integration (integration scaffold generator)
What it is
- Implements the
naas-abi-cli new integrationcommand. - Creates (if needed) a target directory and copies an “integration” template into it using a
Copier.
Public API
-
new_integration(integration_name: str, integration_path: str = ".", extra_values: dict = {})- Normalizes
integration_nameto PascalCase. - Resolves
integration_path("."becomes current working directory). - Ensures the destination directory exists.
- Copies templates from the package’s
cli/new/templates/integrationdirectory into the destination. - Passes template values:
integration_name_pascal: PascalCase integration name- plus any
extra_valuesmerged in.
- Normalizes
-
CLI command:
new integration- Implemented by
_new_integration(integration_name, integration_path=".") - Delegates to
new_integration(...).
- Implemented by
Configuration/Dependencies
- Depends on:
click(CLI arguments and command registration)naas_abi_cli(used to locate the templates directory)naas_abi_cli.cli.utils.Copier.Copier(template copying).utils.to_pascal_case(name normalization)
- Template source directory (computed at runtime):
<naas_abi_cli package dir>/cli/new/templates/integration
Usage
From Python
from naas_abi_cli.cli.new.integration import new_integration
new_integration("my_integration", "./out_dir")
From CLI
naas-abi-cli new integration my_integration .
Caveats
extra_valueshas a mutable default ({}); avoid relying on mutation across calls.integration_nameis always converted to PascalCase; exact transformation depends onto_pascal_case.