CLI Reference
Basic Usage
python -m struct_frame [proto_file] [options]Code Generation Flags
| Flag | Description |
|---|---|
--build_c | Generate C code |
--build_cpp | Generate C++ code |
--build_ts | Generate TypeScript code |
--build_py | Generate Python code |
--build_js | Generate JavaScript code |
--build_gql | Generate GraphQL schema |
--build_csharp | Generate C# code |
--build_rust | Generate Rust code |
Output Path Options
| Flag | Description | Default |
|---|---|---|
--c_path PATH | Output directory for C | generated/c/ |
--cpp_path PATH | Output directory for C++ | generated/cpp/ |
--ts_path PATH | Output directory for TypeScript | generated/ts/ |
--py_path PATH | Output directory for Python | generated/py/ |
--js_path PATH | Output directory for JavaScript | generated/js/ |
--gql_path PATH | Output directory for GraphQL | generated/gql/ |
--csharp_path PATH | Output directory for C# | generated/csharp/ |
--rust_path PATH | Output directory for Rust | generated/rust/ |
SDK Options
| Flag | Description |
|---|---|
--sdk | Include full SDK with transports (C++, Python, TypeScript) |
--sdk_embedded | Include embedded SDK without external dependencies (C++ only) |
C# Options
| Flag | Description | Default |
|---|---|---|
--csharp_namespace NS | Root namespace for generated C# code | StructFrame |
--csharp_sdk | Include C# transport implementations (Serial, TCP, UDP, WebSocket) | |
--target_framework TFM | Target framework for generated .csproj | net8.0 |
Other Options
| Flag | Description |
|---|---|
--equality | Generate equality comparison operators/methods for messages |
--force | Force regeneration even if hash matches previous generation |
--hash_path PATH | Path to store the generation hash file |
--generate_tests | Generate test code with dummy values for round-trip verification |
--no_packed | Generate code without packed structs. Treats every message as variable so that serialization is performed field-by-field. Useful on platforms that do not support struct packing or have different endianness/alignment requirements. |
--validate | Validate the proto file without generating code |
--debug | Enable debug output during code generation |
--catalog_path PATH | Directory for the LSP type catalog file (sf_compile.json); default generated/ |
Examples
Generate C code:
python -m struct_frame messages.proto --build_cGenerate multiple languages:
python -m struct_frame messages.proto --build_c --build_cpp --build_pyCustom output paths:
python -m struct_frame messages.proto --build_c --c_path src/generated/Generate with SDK:
python -m struct_frame messages.proto --build_cpp --sdkGenerate without packed structs (portable encoding):
python -m struct_frame messages.proto --build_c --no_packedWhen --no_packed is used, the C/C++ generators omit the #pragma pack(push, 1) /
#pragma pack(pop) directives around the struct definitions, and every message is
treated as if it had been declared with option variable = true. The generated
<Type>_serialize / <Type>_deserialize (and the C++ serialize / deserialize
methods) then read and write each field individually instead of relying on the
in-memory layout of the struct. This makes the generated code portable across
platforms that lack support for packed structs or have different
endianness/alignment requirements.
Generated Files
C
<name>.structframe.h- Message definitions- Frame utilities (frame_base.h, frame_headers.h, frame_profiles.h, etc.)
C++
<name>.structframe.hpp- Message definitions- Frame utilities (frame_base.hpp, frame_headers.hpp, frame_profiles.hpp, etc.)
struct_frame_sdk/- SDK files (if--sdkor--sdk_embeddedused)
TypeScript
<name>.structframe.ts- Message definitions and classes- Frame utilities (frame-base.ts, frame-headers.ts, frame-profiles.ts, etc.)
struct-frame-sdk/- SDK files (if--sdkused)
Python
struct_frame/generated/<name>.py- Message definitions and classes- Frame utilities (init.py, frame_base.py, frame_profiles.py, etc.)
struct_frame_sdk/- SDK files (if--sdkused)
JavaScript
<name>.structframe.js- Message definitions and classes- Frame parsing utilities
GraphQL
<name>.structframe.graphql- GraphQL schema definitions
C#
<PackageName>/Enums/<EnumName>.cs- Enum definitions (one per enum)<PackageName>/Messages/<MessageName>.cs- Message classes (one per message)<PackageName>/MessageDefinitions.cs- Message registry<PackageName>/SdkInterface.cs- SDK interface (always generated)Framework/- Framing, profiles, types, and SDK coreFramework/Sdk/Transports/- Transport implementations (if--csharp_sdkused)StructFrame.csproj- Project file (always generated)
Rust
<name>.structframe.rs- Message structs withStructFrameMessagetrait implCargo.toml- Crate manifest (always generated)lib.rs- Crate root re-exporting all modules (always generated)- Frame SDK files:
frame_base.rs,frame_headers.rs,payload_types.rs,frame_profiles.rs