hypersdk

HyperExport - New Huh-Based TUI

Overview

The interactive TUI has been completely rewritten using huh (Charm’s form library) instead of the complex Bubbletea implementation. This provides a simpler, more reliable, and more maintainable interface.

What Changed

Old Implementation (Bubbletea)

New Implementation (Huh)

Features

1. VM Selection

2. Export Configuration

3. Confirmation & Summary

4. Export Execution

Orange Theme

The TUI uses a consistent orange color scheme:

Theme is applied to:

Usage

build/hyperexport --interactive

Or with the --tui flag:

build/hyperexport --tui

Workflow

  1. Connect - Automatically connects to vSphere
  2. Load VMs - Fetches list of available VMs
  3. Select - Multi-select interface to choose VMs
  4. Configure - Choose template or customize export settings
  5. Confirm - Review summary and confirm
  6. Export - Executes exports with progress tracking

Code Structure

interactive_huh.go
├── runInteractiveHuh()      # Main entry point
├── selectVMs()               # VM selection interface
├── configureExport()         # Export configuration
├── confirmAndExecute()       # Summary and execution
└── Helper functions
    ├── printBanner()
    ├── truncate()
    ├── sanitizeFilename()

Error Handling

Benefits Over Old Implementation

  1. 95% less code - Easier to understand and maintain
  2. No crashes - Simpler state management, no complex message passing
  3. Better UX - Clear, focused workflow instead of confusing modes
  4. Faster - Less overhead, no complex rendering logic
  5. Maintainable - Simple forms instead of custom UI components
  6. Modern - Uses latest Charm libraries (2026)

Migration Notes

Old Files Backed Up

Old Function

New Function

Dependencies

github.com/charmbracelet/huh v0.8.0        // Form library
github.com/charmbracelet/lipgloss          // Styling
github.com/pterm/pterm                      // Spinners & banners

Future Enhancements

Possible additions (all optional, keep it simple):

Testing

Build and test:

go build -o build/hyperexport ./cmd/hyperexport
build/hyperexport --interactive

The TUI should:

  1. Show HyperExport banner
  2. Connect to vSphere
  3. Load and display VMs
  4. Allow multi-selection
  5. Show configuration options
  6. Execute exports with progress
  7. Report success/failure

Troubleshooting

Q: Forms don’t show orange theme A: Theme is applied via WithTheme(theme) - make sure it’s passed to all forms

Q: Can’t select multiple VMs A: Use spacebar to select, enter to confirm

Q: How to search VMs? A: Forms are filterable - just start typing

Q: Want to cancel? A: Press ESC at any step, or select “No/Cancel” in confirmations