Code Generation Command
The codegen command generates type-safe client libraries from Go source code annotations.
Usage
Description
Scans the VIIPER server codebase to extract:
- API routes and response DTOs
- Device wire formats from
viiper:wirecomment 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.
Flags
--output
Output directory for generated client libraries (relative to repository root).
Default: clients
Environment Variable: VIIPER_CODEGEN_OUTPUT
Example:
--lang
Target language to generate.
Values: c, csharp, typescript, all
Default: all
Environment Variable: VIIPER_CODEGEN_LANG
Examples:
# Generate all client libraries
viiper codegen --lang=all
# Generate C client library only
viiper codegen --lang=c
# Generate C# client library only
viiper codegen --lang=csharp
# Generate TypeScript client library only
viiper codegen --lang=typescript
Examples
Generate All Client Libraries
Generate C Client Library and Rebuild Examples
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 constantsinternal/server/api/*.go: Route registrations- Generator templates in
internal/codegen/generator/
See Also
- Generator Documentation: Detailed explanation of tagging system and code generation flow
- C Client Library Documentation: C-specific usage and build instructions
- Configuration: Global configuration options