Skip to content

Make --target explicit and prompted if flag is missing#278

Open
ejacquier wants to merge 93 commits intomainfrom
feature/DEVSVCS-3827
Open

Make --target explicit and prompted if flag is missing#278
ejacquier wants to merge 93 commits intomainfrom
feature/DEVSVCS-3827

Conversation

@ejacquier
Copy link
Contributor

Summary

  • Removed CRE_TARGET from the generated .env file — target selection is now always explicit
  • When --target flag and CRE_TARGET env var are both missing, the CLI now discovers available targets from project.yaml and either:
    • Auto-selects if only one target exists
    • Prompts the user to choose from a styled interactive select menu if multiple targets exist
  • GetTarget() no longer returns an error when target is unset — it returns empty string and defers to the new promptForTarget() flow
  • Added GetAvailableTargets() to parse project.yaml keys (preserving YAML order) and identify target configurations
  • Updated tests to reflect the new behavior (empty target triggers prompt instead of hard error)

Why

Users were confused about which target they were operating against. The old default (CRE_TARGET=staging-settings in .env) silently picked a target without the user's awareness. Making target selection explicit: via flag, env var, or interactive
prompt, ensures users always know which target they're using.

  - 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
    - 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
…s.go) — An optional []string of chain names in template.yaml.

  Dynamic project.yaml RPC generation (internal/settings/):
  - project.yaml.tpl now uses a {{RPCsList}} placeholder instead of hardcoded chains
  - BuildRPCsListYAML() generates the rpcs YAML block from networks + URLs
  - Falls back to ethereum-testnet-sepolia with default public RPC when no networks specified

  New wizard step (cmd/creinit/wizard.go):
  - stepNetworkRPCs between template selection and workflow name
  - Prompts for each network's RPC URL sequentially
  - Empty input accepted (fill later), non-empty input validated as valid HTTP/HTTPS URL
  - Step is skipped if template has no networks or all RPCs provided via flags

  --rpc-url flag (cmd/creinit/creinit.go):
  - Repeatable StringArray flag: --rpc-url chain-name=url
  - Parsed in ResolveInputs(), merged with wizard results in Execute()
  - Flag values override wizard input
  - Add WorkflowDirEntry struct and Workflows/PostInit fields to
  TemplateMetadata in types.go
  - Rewrite renameWorkflowDir in registry.go to branch on workflow count:
   skip renaming for multi-workflow, rename single workflow, heuristic
  fallback for legacy
  - Update wizard to skip workflow name prompt for multi-workflow
  templates and default placeholder from Workflows[0].Dir
  - Default workflowName from Workflows[0].Dir in non-interactive mode
  - Loop GenerateWorkflowSettingsFile for each declared workflow dir in
  multi-workflow templates
  - Skip workflow.yaml generation when template already ships one
  (prevents overwriting custom config paths)
  - Rewrite printSuccessMessage to show per-workflow summary and postInit
   instructions
  - Add 6 new test cases covering multi-workflow, single-workflow
  defaults, rename with flag, and built-in backwards compat
tarcisiozf
tarcisiozf previously approved these changes Feb 25, 2026
Base automatically changed from feature/dynamic-templates to main February 26, 2026 13:43
@ejacquier ejacquier dismissed tarcisiozf’s stale review February 26, 2026 13:43

The base branch was changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants