Skip to content

Code Generation Command

The codegen command generates type-safe client libraries from Go source code annotations. The command can only be run from the VIIPER repository root with the source code available.

It scans the VIIPER server codebase to extract:

  • API routes and response DTOs
  • Device wire formats from viiper:wire comment tags
  • Device constants (keycodes, modifiers, button masks)

Then generates client libraries with:

  • Management API clients
  • Device-agnostic stream wrappers
  • Per-device encode/decode functions
  • Typed constants and enums

Sourcecode access is required

The codegen command requires access to VIIPER source code. Run it from the repository root.

Usage

viiper codegen [flags]

Description

Flags

--output

Output directory for generated client libraries (relative to repository root).

Default: clients
Environment Variable: VIIPER_CODEGEN_OUTPUT

--lang

Target language to generate.

Values: csharp, typescript, all
Default: all
Environment Variable: VIIPER_CODEGEN_LANG

Examples

Generate All Client Libraries

go run ./cmd/viiper codegen

Generate a Single Client Library

go run ./cmd/viiper codegen --lang=csharp

When to Regenerate

Run codegen when any of these change:

  • /apitypes/*.go: API response structures
  • /device/*/inputstate.go: Wire format annotations
  • /device/*/const.go: Exported constants
  • internal/server/api/*.go: Route registrations
  • Generator templates in internal/codegen/generator/

See Also