Skip to content

archmage enum

The enum subcommand generates typed enum code from definition files, supporting 12+ target languages including C#, Go, 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

Keep the files that --manifest would delete.

Path of the manifest file listing generated files. On the next run, Archmage deletes any files listed in the manifest that are not generated during that run. A relative path is resolved from the output directory.

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 Description
ARCHMAGE_FILE_NAMING_STYLE 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 Indentation style: tab or space. Each template has its own default. Not applicable to the Go template — Go output is always formatted by gofmt.
ARCHMAGE_INDENT_TAB_SIZE 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.
ARCHMAGE_ALL_PUBLIC When set to true, makes all generated types public or exported, depending on the target language.
Variable Description
ARCHMAGE_CPP_STRING_TYPE
(Template: cpp)
C++ string type used in generated code (default: string). Valid values: string, wstring, u8string, u16string, u32string.
ARCHMAGE_GD_CLASS_NAME_SUFFIX
(Template: gd)
Suffix of the class_name in each generated file (default: Enum).
ARCHMAGE_JAVA_OUTER_CLASS_NAME_SUFFIX
(Template: java)
Suffix of the outer class name in each generated file (default: Enum).
ARCHMAGE_JS_MODULE
(Template: js, ts)
Module system. esm → ES module syntax with .mjs/.mts extension; cjs → CommonJS syntax with .cjs/.cts extension.
ARCHMAGE_LUA_VERSION_LT53
(Template: lua)
Set to true for Lua < 5.3 compatibility. This generates bitwise operation fallbacks for environments that lack native bitwise operators.