haniwers.v1.config.generator#
This module handles the generation of configuration files for haniwers. It creates starter configuration files based on templates.
- Usage:
haniwers init [--force] [--no-env]
Module Contents#
Classes#
Types of configuration files that can be generated. |
|
Functions#
Find a template file in possible locations. |
|
Create a file from a template. |
API#
- class haniwers.v1.config.generator.ConfigKind#
Bases:
str,enum.EnumTypes of configuration files that can be generated.
This enum inherits from str to all:
Direct string comparison (kind == “all”)
Automatic string conversion (str(kind))
Easy conversion from string input (ConfigKind(“all”))
Initialization
Initialize self. See help(type(self)) for accurate signature.
- ALL#
‘all’
- CONFIG#
‘config’
- ENV#
‘env’
- haniwers.v1.config.generator.find_template(template_name: str) pathlib.Path | None#
Find a template file in possible locations.
Args: template_name (str): Name of the template file.
Returns: Path | None: Path to the template if found, None otherwise.
- haniwers.v1.config.generator.create_file_from_template(template_name: str, dest_path: pathlib.Path, force: bool = False, replacements: dict[str, str] | None = None, header_comment: str | None = None) bool#
Create a file from a template.
Args: template_name (str): Name of the template file. dest_path (Path): Destination path for the file. force (bool): If True, overwrite existing file without confirmation. replacements (dict[str, str] | None): Dictionary of text replacements to apply. header_comment (str | None): Header comment to add to the file.
Returns: bool: True if successful, False otherwise.
- class haniwers.v1.config.generator.ConfigGenerator(force: bool = False)#
Initialization
- run(kind: haniwers.v1.config.generator.ConfigKind = ConfigKind.ALL) None#
- create_config_file() bool#
- create_env_file() bool#