Selaa lähdekoodia

section achor removed

xcad 5 kuukautta sitten
vanhempi
commit
e809002a82
10 muutettua tiedostoa jossa 6 lisäystä ja 186 poistoa
  1. 2 2
      cli/__main__.py
  2. 2 14
      cli/core/config.py
  3. 0 1
      cli/core/display.py
  4. 0 12
      cli/core/library.py
  5. 0 34
      cli/core/module.py
  6. 0 16
      cli/core/prompt.py
  7. 0 12
      cli/core/registry.py
  8. 1 33
      cli/core/template.py
  9. 0 61
      cli/core/variables.py
  10. 1 1
      pyproject.toml

+ 2 - 2
cli/__main__.py

@@ -17,8 +17,8 @@ import cli.modules
 from cli.core.registry import registry
 # Using standard Python exceptions instead of custom ones
 
-# Version is automatically updated by CI/CD on release
-__version__ = "0.0.1"
+# NOTE: Placeholder version - will be overwritten by release script (.github/workflows/release.yaml)
+__version__ = "0.0.0"
 
 app = Typer(
   help="CLI tool for managing infrastructure boilerplates.\n\n[dim]Easily generate, customize, and deploy templates for Docker Compose, Terraform, Kubernetes, and more.\n\n [white]Made with 💜 by [bold]Christian Lempa[/bold]",

+ 2 - 14
cli/core/config.py

@@ -89,11 +89,7 @@ class ConfigManager:
             Path to the configuration file.
         """
         return self.config_path
-    
-    # -------------------------
-    # SECTION: Defaults Management
-    # -------------------------
-    
+
     def get_defaults(self, module_name: str) -> Dict[str, Any]:
         """Get default variable values for a module.
         
@@ -168,13 +164,7 @@ class ConfigManager:
             del config["defaults"][module_name]
             self._write_config(config)
             logger.info(f"Cleared defaults for module '{module_name}'")
-    
-    # !SECTION
-    
-    # -------------------------
-    # SECTION: Preferences Management
-    # -------------------------
-    
+
     def get_preference(self, key: str) -> Optional[Any]:
         """Get a user preference value.
         
@@ -212,5 +202,3 @@ class ConfigManager:
         """
         config = self._read_config()
         return config.get("preferences", {})
-    
-    # !SECTION

+ 0 - 1
cli/core/display.py

@@ -329,4 +329,3 @@ class DisplayManager:
             logger.warning(f"Failed to render next_steps as template: {e}")
             # Fallback to plain text if rendering fails
             console.print(next_steps)
-

+ 0 - 12
cli/core/library.py

@@ -7,10 +7,6 @@ from typing import Optional
 logger = logging.getLogger(__name__)
 
 
-# -----------------------
-# SECTION: Library Class
-# -----------------------
-
 class Library:
   """Represents a single library with a specific path."""
   
@@ -137,12 +133,6 @@ class Library:
     logger.debug(f"Found {len(template_dirs)} templates in module '{module_name}'")
     return template_dirs
 
-# !SECTION
-
-# -----------------------------
-# SECTION: LibraryManager Class
-# -----------------------------
-
 class LibraryManager:
   """Manages multiple libraries and provides methods to find templates."""
   
@@ -219,5 +209,3 @@ class LibraryManager:
     
     logger.debug(f"Found {len(unique_templates)} unique templates total")
     return unique_templates
-
-# !SECTION

+ 0 - 34
cli/core/module.py

@@ -19,10 +19,6 @@ logger = logging.getLogger(__name__)
 console = Console()
 
 
-# ------------------------------- 
-# SECTION: Helper Functions
-# ------------------------------- 
-
 def parse_var_inputs(var_options: list[str], extra_args: list[str]) -> dict[str, Any]:
   """Parse variable inputs from --var options and extra args.
   
@@ -53,12 +49,6 @@ def parse_var_inputs(var_options: list[str], extra_args: list[str]) -> dict[str,
   
   return variables
 
-# !SECTION
-
-# ---------------------
-# SECTION: Module Class
-# ---------------------
-
 class Module(ABC):
   """Streamlined base module that auto-detects variables from templates."""
 
@@ -73,10 +63,6 @@ class Module(ABC):
     self.libraries = LibraryManager()
     self.display = DisplayManager()
 
-  # --------------------------
-  # SECTION: Public Commands
-  # --------------------------
-
   def list(self) -> list[Template]:
     """List all templates."""
     logger.debug(f"Listing templates for module '{self.name}'")
@@ -320,10 +306,6 @@ class Module(ABC):
       # Stop execution without letting Typer/Click print the exception again.
       raise Exit(code=1)
 
-  # --------------------------
-  # SECTION: Config Commands
-  # --------------------------
-
   def config_get(
     self,
     var_name: Optional[str] = Argument(None, help="Variable name to get (omit to show all defaults)"),
@@ -581,12 +563,6 @@ class Module(ABC):
       else:
         console.print(f"\n[green] All templates are valid![/green]")
 
-  # !SECTION
-
-  # ------------------------------
-  # SECTION: CLI Registration
-  # ------------------------------
-
   @classmethod
   def register_cli(cls, app: Typer) -> None:
     """Register module commands with the main app."""
@@ -618,14 +594,6 @@ class Module(ABC):
     app.add_typer(module_app, name=cls.name, help=cls.description)
     logger.info(f"Module '{cls.name}' CLI commands registered")
 
-  # !SECTION
-
-
-
-  # --------------------------
-  # SECTION: Private Methods
-  # --------------------------
-
   def _load_template_by_id(self, template_id: str) -> Template:
     result = self.libraries.find_by_id(self.name, template_id)
     if not result:
@@ -645,5 +613,3 @@ class Module(ABC):
   def _display_template_details(self, template: Template, template_id: str) -> None:
     """Display template information panel and variables table."""
     self.display.display_template_details(template, template_id)
-
-# !SECTION

+ 0 - 16
cli/core/prompt.py

@@ -12,10 +12,6 @@ from .variables import Variable, VariableCollection
 logger = logging.getLogger(__name__)
 
 
-# ---------------------------
-# SECTION: PromptHandler Class
-# ---------------------------
-
 class PromptHandler:
   """Simple interactive prompt handler for collecting template variables."""
 
@@ -23,10 +19,6 @@ class PromptHandler:
     self.console = Console()
     self.display = DisplayManager()
 
-  # --------------------------
-  # SECTION: Public Methods
-  # --------------------------
-
   def collect_variables(self, variables: VariableCollection) -> dict[str, Any]:
     """Collect values for variables by iterating through sections.
     
@@ -98,12 +90,6 @@ class PromptHandler:
     logger.info(f"Variable collection completed. Collected {len(collected)} values")
     return collected
 
-  # !SECTION
-
-  # ---------------------------
-  # SECTION: Private Methods
-  # ---------------------------
-
   def _prompt_variable(self, variable: Variable, required: bool = False) -> Any:
     """Prompt for a single variable value based on its type."""
     logger.debug(f"Prompting for variable '{variable.name}' (type: {variable.type})")
@@ -213,5 +199,3 @@ class PromptHandler:
       if value in options:
         return value
       self.console.print(f"[red]Invalid choice. Select from: {', '.join(options)}[/red]")
-
-# !SECTION

+ 0 - 12
cli/core/registry.py

@@ -7,10 +7,6 @@ from typing import Iterator, Type
 logger = logging.getLogger(__name__)
 
 
-# ------------------------------
-# SECTION: ModuleRegistry Class
-# ------------------------------
-
 class ModuleRegistry:
   """Simple module registry without magic."""
   
@@ -36,13 +32,5 @@ class ModuleRegistry:
     for name in sorted(self._modules.keys()):
       yield name, self._modules[name]
 
-# !SECTION
-
-# -------------------------
-# SECTION: Global Instance
-# -------------------------
-
 # Global registry
 registry = ModuleRegistry()
-
-# !SECTION

+ 1 - 33
cli/core/template.py

@@ -14,10 +14,6 @@ from jinja2.visitor import NodeVisitor
 logger = logging.getLogger(__name__)
 
 
-# -----------------------
-# SECTION: TemplateFile Class
-# -----------------------
-
 @dataclass
 class TemplateFile:
     """Represents a single file within a template directory."""
@@ -25,12 +21,6 @@ class TemplateFile:
     file_type: Literal['j2', 'static']
     output_path: Path # The path it will have in the output directory
 
-# !SECTION
-
-# -----------------------
-# SECTION: Metadata Class
-# -----------------------
-
 @dataclass
 class TemplateMetadata:
   """Represents template metadata with proper typing."""
@@ -106,12 +96,6 @@ class TemplateMetadata:
     if missing_fields:
       raise ValueError(f"Template format error: missing required metadata fields: {missing_fields}")
 
-# !SECTION
-
-# -----------------------
-# SECTION: Template Class
-# -----------------------
-
 @dataclass
 class Template:
   """Represents a template directory."""
@@ -355,10 +339,6 @@ class Template:
     
     return filtered_specs
 
-  # ---------------------------
-  # SECTION: Validation Methods
-  # ---------------------------
-
   @staticmethod
   def _validate_kind(template_data: dict) -> None:
     """Validate that template has required 'kind' field.
@@ -402,12 +382,6 @@ class Template:
       logger.error(error_msg)
       raise ValueError(error_msg)
 
-  # !SECTION
-
-  # ---------------------------------
-  # SECTION: Jinja2 Rendering Methods
-  # ---------------------------------
-
   @staticmethod
   def _create_jinja_env(searchpath: Path) -> Environment:
     """Create standardized Jinja2 environment for consistent template processing.
@@ -577,12 +551,6 @@ class Template:
       
     return masked_files
   
-  # !SECTION
-
-  # ---------------------------
-  # SECTION: Lazy Loaded Properties
-  # ---------------------------
-
   @property
   def template_files(self) -> List[TemplateFile]:
       if self.__template_files is None:
@@ -646,4 +614,4 @@ class Template:
           self.__variables = VariableCollection(filtered_specs)
           # Sort sections: required first, then enabled, then disabled
           self.__variables.sort_sections()
-      return self.__variables
+      return self.__variables

+ 0 - 61
cli/core/variables.py

@@ -9,22 +9,12 @@ import re
 
 logger = logging.getLogger(__name__)
 
-# -----------------------
-# SECTION: Constants
-# -----------------------
-
 TRUE_VALUES = {"true", "1", "yes", "on"}
 FALSE_VALUES = {"false", "0", "no", "off"}
 HOSTNAME_REGEX = re.compile(r"^(?=.{1,253}$)(?!-)[A-Za-z0-9_-]{1,63}(?<!-)(\.(?!-)[A-Za-z0-9_-]{1,63}(?<!-))*$")
 EMAIL_REGEX = re.compile(r"^[^@\s]+@[^@\s]+\.[^@\s]+$")
 
 
-# !SECTION
-
-# ----------------------
-# SECTION: Variable Class
-# ----------------------
-
 class Variable:
   """Represents a single templating variable with lightweight validation."""
 
@@ -70,10 +60,6 @@ class Variable:
       except ValueError as exc:
         raise ValueError(f"Invalid default for variable '{self.name}': {exc}")
 
-  # -------------------------
-  # SECTION: Validation Helpers
-  # -------------------------
-
   def _validate_not_empty(self, value: Any, converted_value: Any) -> None:
     """Validate that a value is not empty for non-boolean types."""
     if self.type not in ["bool"] and (converted_value is None or converted_value == ""):
@@ -94,12 +80,6 @@ class Variable:
     if not (parsed_url.scheme and parsed_url.netloc):
       raise ValueError("value must be a valid URL (include scheme and host)")
 
-  # !SECTION
-
-  # -------------------------
-  # SECTION: Type Conversion
-  # -------------------------
-
   def convert(self, value: Any) -> Any:
     """Validate and convert a raw value based on the variable type."""
     if value is None:
@@ -236,10 +216,6 @@ class Variable:
     
     return var_dict
   
-  # -------------------------
-  # SECTION: Display Methods
-  # -------------------------
-  
   def get_display_value(self, mask_sensitive: bool = True, max_length: int = 30) -> str:
     """Get formatted display value with optional masking and truncation.
     
@@ -379,14 +355,6 @@ class Variable:
     
     return cloned
   
-  # !SECTION
-
-# !SECTION
-
-# ----------------------------
-# SECTION: VariableSection Class
-# ----------------------------
-
 class VariableSection:
   """Groups variables together with shared metadata for presentation."""
 
@@ -458,10 +426,6 @@ class VariableSection:
     
     return section_dict
   
-  # -------------------------
-  # SECTION: State Methods
-  # -------------------------
-  
   def is_enabled(self) -> bool:
     """Check if section is currently enabled based on toggle variable.
     
@@ -530,14 +494,6 @@ class VariableSection:
         cloned.variables[var_name] = variable.clone()
     
     return cloned
-  
-  # !SECTION
-
-# !SECTION
-
-# --------------------------------
-# SECTION: VariableCollection Class
-# --------------------------------
 
 class VariableCollection:
   """Manages variables grouped by sections and builds Jinja context."""
@@ -802,10 +758,6 @@ class VariableCollection:
     
     return result
 
-  # -------------------------
-  # SECTION: Public API Methods
-  # -------------------------
-
   def get_sections(self) -> Dict[str, VariableSection]:
     """Get all sections in the collection."""
     return self._sections.copy()
@@ -860,15 +812,6 @@ class VariableCollection:
     """Get only the sensitive variables with their values."""
     return {name: var.value for name, var in self._variable_map.items() if var.sensitive and var.value}
 
-  # !SECTION
-
-  # -------------------------
-  # SECTION: Helper Methods
-  # -------------------------
-
-  # NOTE: These helper methods reduce code duplication across module.py and prompt.py
-  # by centralizing common variable collection operations
-
   def apply_defaults(self, defaults: dict[str, Any], origin: str = "cli") -> list[str]:
     """Apply default values to variables, updating their origin.
     
@@ -1147,7 +1090,3 @@ class VariableCollection:
         Set of all variable names
     """
     return set(self._variable_map.keys())
-
-  # !SECTION
-
-# !SECTION

+ 1 - 1
pyproject.toml

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
 
 [project]
 name = "boilerplates"
-version = "0.0.1"
+version = "0.0.0"  # NOTE: Placeholder - will be overwritten by release script
 description = "CLI tool for managing infrastructure boilerplates"
 readme = "README.md"
 requires-python = ">=3.9"