cli

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package cli implements the Nexus CLI command tree.

This file defines the `nexus add` parent command and its subcommands:

  • `nexus add entity` — scaffold a new domain entity across all layers
  • `nexus add protocol` — add a protocol adapter to an existing project
  • `nexus add middleware` — scaffold a new mesh middleware

The `nexus add` command itself does nothing — it only groups subcommands. Running `nexus add` without a subcommand prints the help text showing all available sub-commands.

These are stubs for now. Full implementations will arrive in:

  • Phase 8 (entity scaffolding)
  • Phase 10 (protocol and middleware scaffolding)

Package cli implements the Nexus CLI command tree.

This file implements the `nexus add entity` command — the entry point for entity scaffolding. It supports two modes:

  1. CLI mode: `nexus add entity User --fields "name:string:required email:string:unique"` All entity details are provided via flags. No interactivity required.

  2. Interactive mode: `nexus add entity` If the entity name or fields are not provided, the command launches a series of prompts to collect the entity definition from the user.

After collecting the entity definition, this file delegates to the scaffold package (internal/scaffold) which handles template rendering, file writing, manifest updating, and main.go patching.

Design Decisions:

  • We keep the CLI layer thin. It only parses flags, builds a manifest.Entity, and delegates to the scaffolder. No business logic lives here.
  • Interactive mode uses simple fmt.Scan prompts rather than bubbletea TUI components. This is pragmatic: entity scaffolding is a quick operation that doesn't benefit from the full TUI treatment. The TUI framework is reserved for the init wizard where the experience matters more.
  • The --fields flag uses a compact DSL: "name:type[:modifiers]" separated by spaces. This is easy to type and parse, and familiar to Rails/Django developers.

Package cli implements the Nexus CLI command tree.

Note regarding `.injector.go.swp`: A `.swp` file is a temporary swap file created automatically by text editors like Vim or Neovim. It stores unsaved changes and cursor position state, acting as a crash recovery mechanism. When the editor closes normally, the swap file is deleted. If the editor crashes or the file is kept open in another terminal, the `.swp` file is left behind. It should generally be ignored via `.gitignore`.

This file defines the `nexus add k8s` command.

Package cli implements the Nexus CLI command tree.

This file defines the `nexus build` command, which compiles the generated Nexus project into an optimized production binary. It runs `go build` with appropriate linker flags (-s -w for symbol stripping, -trimpath for reproducible builds) and reports the resulting binary size and build time.

The build command reads the nexus.yml manifest to determine the project name, entry point path, and version information for injection via -ldflags.

For now this is a stub that prints a placeholder message. The full implementation will arrive in Phase 10.

Package cli implements the Nexus CLI command tree.

This file defines the `nexus doctor` command, which scans an existing Nexus project and produces a styled diagnostic report. It checks for structural correctness, missing tests, out-of-sync proto files, unused middleware, and other common issues.

The doctor assigns an overall health score (0-10) with color-coded severity levels for each finding:

  • ✓ (green) — everything is correct
  • ⚠ (yellow) — warning, non-blocking but worth fixing
  • ✗ (red) — error, something is broken or missing

For now this is a stub that prints a placeholder message. The full diagnostic engine implementation lives in Phase 10 (internal/doctor/).

Package cli implements the Nexus CLI command tree.

This file defines the `nexus init` command, which launches an interactive TUI wizard to scaffold a new Go backend project. The wizard collects project configuration (name, protocols, database, auth, middleware, infrastructure) via a multi-step bubbletea program and produces a generator.ProjectConfig struct ready for the code generation engine.

If a project name is provided as a positional argument, it is pre-filled into the wizard's project name field. Otherwise, the wizard prompts for it.

The wizard runs in an alternate screen buffer so it does not pollute the user's scrollback history. On completion, the ProjectConfig is passed to the generator engine which renders templates and writes the project to disk. Progress is fed back to the generating screen in real time. On cancellation (Ctrl+C), the command prints a styled "Cancelled." message and exits cleanly.

Package cli implements the Nexus CLI command tree.

This is the top-level package that wires together all cobra commands and provides the Execute() entry point called from main(). Each command is defined in its own file (init.go, version.go, stress.go, etc.) and registered on the root command via init() functions.

The root command itself does nothing except display the styled help. All real functionality lives in subcommands.

Design Decisions:

  • We use cobra for the CLI framework because it is the industry standard for Go CLI applications. It provides excellent help generation, shell completion, and a well-understood command/flag pattern.
  • Global flags (--verbose, --no-color) are defined on the root command and available to all subcommands via PersistentFlags.
  • The ASCII art logo is rendered with lipgloss for beautiful terminal output. If --no-color is set, lipgloss respects that automatically.

Package cli implements the Nexus CLI command tree.

This file defines the `nexus serve` command, which runs the generated Nexus project in development mode. It executes `go run ./cmd/server` in the current project directory, with optional file-watching for automatic restarts on code changes.

The serve command reads the nexus.yml manifest to determine the project structure and passes through relevant environment variables for configuration (ports, log level, database path, etc.).

For now this is a stub that prints a placeholder message. The full implementation will arrive in Phase 10.

Package cli implements the Nexus CLI command tree.

This file defines the `nexus stress` command, which provides built-in multi-protocol load testing for Go backend systems. It supports HTTP/REST, WebSocket, and gRPC load generation with real-time metrics display and styled terminal reports.

The stress tester can operate in two modes:

  • Direct mode: target a single URL with flags for rate, duration, etc.
  • Scenario mode: load a YAML scenario file with multiple phases and targets

For now this is a stub that prints a placeholder message. The full stress testing engine implementation lives in Phase 9 (internal/stress/).

Package cli implements the Nexus CLI command tree.

This file defines the `nexus version` command, which displays build-time version information in a styled, lipgloss-rendered key-value format.

Output includes:

  • Version tag (e.g., "v0.1.0" or "dev")
  • Git commit hash
  • Build timestamp
  • Go compiler version
  • OS/architecture

The output adapts to --no-color mode automatically via lipgloss.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorError

func ColorError() lipgloss.Color

ColorError returns the error theme color.

func ColorMuted

func ColorMuted() lipgloss.Color

ColorMuted returns the muted theme color.

func ColorPrimary

func ColorPrimary() lipgloss.Color

ColorPrimary returns the primary theme color for use in subcommands.

func ColorSecondary

func ColorSecondary() lipgloss.Color

ColorSecondary returns the secondary theme color.

func ColorSuccess

func ColorSuccess() lipgloss.Color

ColorSuccess returns the success theme color.

func ColorWarning

func ColorWarning() lipgloss.Color

ColorWarning returns the warning theme color.

func Execute

func Execute()

Execute runs the root command. This is the single entry point called from main(). It parses os.Args, routes to the appropriate subcommand, and handles any top-level errors with styled output.

func MutedStyle

func MutedStyle() lipgloss.Style

MutedStyle returns the styled renderer for muted/secondary text.

func SectionStyle

func SectionStyle() lipgloss.Style

SectionStyle returns the styled renderer for section headers.

func Verbose

func Verbose() bool

Verbose returns whether the --verbose flag is set. Subcommands use this to decide whether to print debug information.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL