Skip to content

archmage enum

The enum subcommand generates typed enum code from definition files, supporting 12 target languages including Go, C#, Java, Python, TypeScript, JavaScript, Lua, GDScript, C++, Rust, PHP, and Protocol Buffers.

See Enum Definition and Enum Code Features for more information.

Terminal window
archmage enum -t <template> -o <output-dir> <file1> [<file2> ...]

Input files may be specified as literal paths or glob patterns.

Terminal window
# Generate Go code from a single file
archmage enum -t go -o ./enums idl/combat.enum.yaml
# Generate C# code from multiple files using a glob
archmage enum -t cs -o ./Enums "idl/*.enum.yaml"

The directory where generated files are written.

The code template to use. Accepts either a built-in template name (see Built-in Templates) or a path to a custom template file.

Terminal window
archmage enum -t go -o ./enums idl/combat.enum.yaml
archmage enum -t ./my-enum.tpl -o ./enums idl/combat.enum.yaml

Comma-separated scenario flags. When set, enum types and items whose xflags don’t match are excluded from the output.

Terminal window
# Generate enums matching the client scenario
archmage enum -t go -o ./enums -x c idl/combat.enum.yaml
# Include both client and server
archmage enum -t go -o ./enums -x c,s idl/combat.enum.yaml

Print the Archmage banner on startup.

Write all output files with CRLF (\r\n) line endings instead of LF (\n).

Change the working directory before running. Relative paths are resolved from this directory.

Terminal window
archmage enum -t go -o ./enums --cwd /workspace/game idl/combat.enum.yaml

Load environment variables from the specified file before running. If omitted and a .env file exists in the working directory, it’s loaded automatically.

Terminal window
archmage enum -t go -o ./enums --dotenv config/archmage.env idl/combat.enum.yaml

Process all input files and validate them without writing any output. Useful for checking that definition files are well-formed before committing to generation.

Terminal window
archmage enum -t go -o ./enums --dry-run idl/combat.enum.yaml

The bit size of the int and uint types — either 32 or 64 (default: 64).

Terminal window
archmage enum -t go -o ./enums --int-bit-size 32 idl/combat.enum.yaml

Print extra status messages.

Name Language
go Go
cs C#
java Java
py Python
ts TypeScript
js JavaScript
lua Lua
gd GDScript
cpp C++
rs Rust
php PHP
proto Protocol Buffers

Environment variables fine-tune output behavior for things that require cross-layer penetration — file naming, indentation style, language-specific options, etc.

These variables are recognized by all or most built-in templates.

Variable Default Description
ARCHMAGE_FILE_NAMING_STYLE Varies by template Naming style for output files. Common values: snake, kebab, pascal, camel. When omitted, each template falls back to its own default (e.g. pascal for C#).
ARCHMAGE_INDENT_STYLE Varies by template Indentation style: tab or space. Not applicable to the Go template — Go output is always formatted by gofmt.
ARCHMAGE_INDENT_TAB_SIZE Varies by template Number of spaces per indent level when ARCHMAGE_INDENT_STYLE is space. Each template has its own default (commonly 2 or 4). Not applicable to the Go template.
ARCHMAGE_OUTPUT_ENV When set to true, generates an archmage.env file alongside the enum output. It records all environment variables used by the current template, which is useful for build reproducibility and debugging.
Variable Default Description
ARCHMAGE_CPP_STRING_TYPE
(Template: cpp)
string C++ string type used in generated code. Valid values: string, wstring, u8string, u16string, u32string.
ARCHMAGE_JS_MODULE
(Template: js, ts)
esm Module system. esm → ES module syntax with .mjs/.mts extension; cjs → CommonJS syntax with .cjs/.cts extension.
ARCHMAGE_LUA_VERSION_LT53
(Template: lua)
false Set to true for Lua < 5.3 compatibility. This generates bitwise operation fallbacks for environments that lack native bitwise operators.