Browse Source

feat: show (none) for empty values and make overrides bold

- Display '(none)' in dimmed text for all empty/None values
- Add show_none parameter to get_display_value() for consistent handling
- Make config override arrow and value bold yellow for better visibility
- Simplify display logic by centralizing empty value handling
xcad 4 months ago
parent
commit
8b35e92097
2 changed files with 15 additions and 11 deletions
  1. 11 8
      cli/core/display.py
  2. 4 3
      cli/core/variables.py

+ 11 - 8
cli/core/display.py

@@ -291,22 +291,25 @@ class DisplayManager:
                 if (variable.origin == "config" and 
                     hasattr(variable, '_original_stored') and
                     variable.original_value != variable.value):
-                    # Format original value (mask if sensitive, show (none) if None)
+                    # Format original value (use same display logic, but shorter)
                     if variable.sensitive:
                         orig_display = "********"
-                    elif variable.original_value is None:
+                    elif variable.original_value is None or variable.original_value == "":
                         orig_display = "[dim](none)[/dim]"
                     else:
                         orig_val_str = str(variable.original_value)
                         orig_display = orig_val_str[:15] + "..." if len(orig_val_str) > 15 else orig_val_str
                     
-                    # Get current (config) value display
-                    config_display = variable.get_display_value(mask_sensitive=True, max_length=15)
-                    # Highlight the arrow and config value in yellow to show it's a custom override
-                    default_val = f"{orig_display} [yellow]{IconManager.arrow_right()} {config_display}[/yellow]"
+                    # Get current (config) value display (without showing "(none)" since we have the arrow)
+                    config_display = variable.get_display_value(mask_sensitive=True, max_length=15, show_none=False)
+                    if not config_display:  # If still empty after show_none=False, show actual value
+                        config_display = str(variable.value) if variable.value else "(empty)"
+                    
+                    # Highlight the arrow and config value in bold yellow to show it's a custom override
+                    default_val = f"{orig_display} [bold yellow]{IconManager.arrow_right()} {config_display}[/bold yellow]"
                 else:
-                    # Use variable's native get_display_value() method
-                    default_val = variable.get_display_value(mask_sensitive=True, max_length=30)
+                    # Use variable's native get_display_value() method (shows "(none)" for empty)
+                    default_val = variable.get_display_value(mask_sensitive=True, max_length=30, show_none=True)
                 
                 # Add lock icon for sensitive variables
                 sensitive_icon = f" {IconManager.lock()}" if variable.sensitive else ""

+ 4 - 3
cli/core/variables.py

@@ -218,18 +218,19 @@ class Variable:
     
     return var_dict
   
-  def get_display_value(self, mask_sensitive: bool = True, max_length: int = 30) -> str:
+  def get_display_value(self, mask_sensitive: bool = True, max_length: int = 30, show_none: bool = True) -> str:
     """Get formatted display value with optional masking and truncation.
     
     Args:
         mask_sensitive: If True, mask sensitive values with asterisks
         max_length: Maximum length before truncation (0 = no limit)
+        show_none: If True, display "(none)" for None values instead of empty string
         
     Returns:
         Formatted string representation of the value
     """
-    if self.value is None:
-      return ""
+    if self.value is None or self.value == "":
+      return "[dim](none)[/dim]" if show_none else ""
     
     # Mask sensitive values
     if self.sensitive and mask_sensitive: