Modernizes the CRE CLI's user interface by integrating the Charm ecosystem#243
Modernizes the CRE CLI's user interface by integrating the Charm ecosystem#243
Conversation
- Create internal/ui/ package with centralized Lipgloss styles (styles.go) - Add output helpers for consistent styling: Title, Box, Success, Dim, etc. - Implement Bubble Tea spinner with reference counting for async operations - Add GlobalSpinner singleton for seamless spinner across CLI lifecycle - Update PersistentPreRunE to show spinner during initialization - Migrate cre init and cre whoami to use shared UI package
- Add spinner during file generation (copying, generating templates, contracts) - Show spinner during Go dependencies installation - Display dependencies in styled box after spinner completes - Fix Next steps box spacing and formatting - Refactor initializeGoModule to return deps instead of printing
- Add styled template functions (styleTitle, styleSection, styleCommand, styleDim, styleSuccess, styleCode) - Update help template to use Lipgloss styling - Style section headers, command names, tips, and URLs - Improve visual hierarchy and readability
- Add complete Blocks palette constants (Gray, Blue, Green, Red, Orange, Yellow, Teal, Purple) - Use high-contrast colors for dark terminal readability - Style titles/commands with Blue 400-500 for visibility - Style secondary info with Gray 500 (dimmed) - Create custom Huh theme with Blocks colors for forms - Update spinner to use Blue 500
- Add styled title and welcome message using Chainlink theme
- Add Bubble Tea spinner with progress states throughout auth flow:
- Preparing authentication
- Opening browser
- Waiting for authentication
- Exchanging authorization code
- Saving credentials
- Show styled URL fallback when browser cannot open automatically
- Display success message with next steps in branded box
- Update spinner message during org membership retry flow
- Update tests to include spinner in handler instantiations
- Add SilenceErrors: true to root command to disable Cobra's default error output - Display all user-facing errors with styled ui.Error() in Execute() - Errors now show with red color and ✗ prefix consistent with Chainlink theme - Internal debug logging via zerolog remains unchanged
- Add SilenceErrors: true to disable Cobra's default error output - Display errors with styled ui.Error() (red with ✗ prefix) - Set SilenceUsage in PersistentPreRunE to hide usage for runtime errors - Keep usage/suggestions visible for command typos and flag errors
consistent styling across the CLI
- Replaced prompt.YesNoPrompt with huh.NewConfirm forms
- Removed stdin io.Reader parameter
2. Updated cmd/creinit/creinit.go:
- Updated call sites to match new function signatures
3. Updated cmd/secrets/common/handler.go:
- Replaced ~25 fmt.Print* calls with ui.* functions
4. Updated cmd/workflow/simulate/telemetry_writer.go:
- Replaced fmt.Printf with ui.Printf
- Removed unused fmt import
5. Deleted internal/prompt/ directory:
- Removed entire old promptui-based package
6. Cleaned cmd/common/utils.go:
- Removed unused MustGetUserInputWithPrompt function
- Removed unused bufio and errors imports
7. Dependencies cleaned (go mod tidy):
- Removed github.com/manifoldco/promptui
- Removed github.com/chzyer/readline
|
🚀 Preview Build Artifacts You can download the preview builds for this PR from the following URL: https://github.com/smartcontractkit/cre-cli/actions/runs/21969226069 Note: These are preview builds and are not signed. |
|
🚀 Preview Build Artifacts You can download the preview builds for this PR from the following URL: https://github.com/smartcontractkit/cre-cli/actions/runs/21969768891 Note: These are preview builds and are not signed. |
…actkit/cre-cli into feature/charm-lib-refactoring
| var excludedCommands = map[string]struct{}{ | ||
| "cre version": {}, | ||
| "cre login": {}, | ||
| "cre logout": {}, |
There was a problem hiding this comment.
Is the token still invalidated on logout when the command is excluded?
There was a problem hiding this comment.
Yes it is still invalidated. The isLoadCredentials exclusion only prevents PersistentPreRunE from calling runtimeContext.AttachCredentials().
| stderrStr := stderr.String() | ||
| // Cobra may say "accepts 1 arg(s)" or "requires" depending on the command definition. | ||
| // We just verify stderr is non-empty and stdout doesn't contain the error. | ||
| assert.NotEmpty(t, stderrStr, "expected error output on stderr, got nothing.\nSTDOUT: %s", stdout.String()) |
| ui.WithLabels("Yes, login", "No, cancel"), | ||
| ) | ||
| if formErr != nil { | ||
| return fmt.Errorf("authentication required: %w", err) |
|
🚀 Preview Build Artifacts You can download the preview builds for this PR from the following URL: https://github.com/smartcontractkit/cre-cli/actions/runs/22101301165 Note: These are preview builds and are not signed. |
2. Replaced os.Exit(0) with return errLoginCompleted in PersistentPreRunE after successful auto-login 3. Added sentinel check in Execute() — when the error is errLoginCompleted, keeps exit code 0, clears the error (so telemetry records success, not failure), and skips ui.Error()
|
🚀 Preview Build Artifacts You can download the preview builds for this PR from the following URL: https://github.com/smartcontractkit/cre-cli/actions/runs/22105338078 Note: These are preview builds and are not signed. |
|
| Version | Value |
|---|---|
| Current Fork | v1.16.0 |
| Latest Upstream | v1.17.0 |
Action Required
- Review abigen changes in upstream (only the
accounts/abi/binddirectory matters) - Compare with our fork in
cmd/generate-bindings/bindings/abigen/ - If relevant changes exist, sync them and update
FORK_METADATA.md - If no abigen changes, just update the version in
FORK_METADATA.mdtov1.17.0
Files to Review
cmd/generate-bindings/bindings/abigen/bind.gocmd/generate-bindings/bindings/abigen/bindv2.gocmd/generate-bindings/bindings/abigen/template.go
cc @smartcontractkit/bix-framework
|
🚀 Preview Build Artifacts You can download the preview builds for this PR from the following URL: https://github.com/smartcontractkit/cre-cli/actions/runs/22106242246 Note: These are preview builds and are not signed. |
|
| Version | Value |
|---|---|
| Current Fork | v1.16.0 |
| Latest Upstream | v1.17.0 |
Action Required
- Review abigen changes in upstream (only the
accounts/abi/binddirectory matters) - Compare with our fork in
cmd/generate-bindings/bindings/abigen/ - If relevant changes exist, sync them and update
FORK_METADATA.md - If no abigen changes, just update the version in
FORK_METADATA.mdtov1.17.0
Files to Review
cmd/generate-bindings/bindings/abigen/bind.gocmd/generate-bindings/bindings/abigen/bindv2.gocmd/generate-bindings/bindings/abigen/template.go
cc @smartcontractkit/bix-framework
|
🚀 Preview Build Artifacts You can download the preview builds for this PR from the following URL: https://github.com/smartcontractkit/cre-cli/actions/runs/22106748616 Note: These are preview builds and are not signed. |
|
| Version | Value |
|---|---|
| Current Fork | v1.16.0 |
| Latest Upstream | v1.17.0 |
Action Required
- Review abigen changes in upstream (only the
accounts/abi/binddirectory matters) - Compare with our fork in
cmd/generate-bindings/bindings/abigen/ - If relevant changes exist, sync them and update
FORK_METADATA.md - If no abigen changes, just update the version in
FORK_METADATA.mdtov1.17.0
Files to Review
cmd/generate-bindings/bindings/abigen/bind.gocmd/generate-bindings/bindings/abigen/bindv2.gocmd/generate-bindings/bindings/abigen/template.go
cc @smartcontractkit/bix-framework
|
🚀 Preview Build Artifacts You can download the preview builds for this PR from the following URL: https://github.com/smartcontractkit/cre-cli/actions/runs/22108252983 Note: These are preview builds and are not signed. |
|
| Version | Value |
|---|---|
| Current Fork | v1.16.0 |
| Latest Upstream | v1.17.0 |
Action Required
- Review abigen changes in upstream (only the
accounts/abi/binddirectory matters) - Compare with our fork in
cmd/generate-bindings/bindings/abigen/ - If relevant changes exist, sync them and update
FORK_METADATA.md - If no abigen changes, just update the version in
FORK_METADATA.mdtov1.17.0
Files to Review
cmd/generate-bindings/bindings/abigen/bind.gocmd/generate-bindings/bindings/abigen/bindv2.gocmd/generate-bindings/bindings/abigen/template.go
cc @smartcontractkit/bix-framework
|
🚀 Preview Build Artifacts You can download the preview builds for this PR from the following URL: https://github.com/smartcontractkit/cre-cli/actions/runs/22109282990 Note: These are preview builds and are not signed. |
Summary
This PR modernizes the CRE CLI's user interface by integrating the Charm ecosystem (Lipgloss, Huh, Bubble Tea). This is a view-layer only refactoring - no business logic or Cobra command structure was modified.
Why This Refactoring?
To build a world-class developer experience, we needed a better foundation. Our previous approach had limitations:
fmt.Printcalls can't handle async operations gracefullypromptuilibrary offered limited customization and no modern UX patternsThe Charm ecosystem solves these by owning the terminal - it manages the view layer as a proper UI framework, enabling:
Key Changes
1. New UI Package (
internal/ui/)Centralized styling and output functions:
2. Chainlink-Branded Theme
All interactive elements use the Chainlink color palette:
#375BD2): Primary actions, spinners, focused elements3. Spinner for Async Operations
Reference-counted spinner that handles concurrent operations:
4. Modern Form Inputs with Huh
Replaced
promptuiwithhuhforms featuring:5. Enhanced Error Handling
New helpers for actionable error messages:
6. Graceful Cancellation
Long-running operations (like
cre login) now support Escape/Ctrl+C with proper cleanup and user feedback.What's NOT Changed
Libraries
Removed Dependencies
promptui- Replaced entirely byhuhTesting