Skip to content

Commit 271db0a

Browse files
committed
docs(readme): document --initialism behavior and interactions
1 parent ba8dd94 commit 271db0a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ GLOBAL OPTIONS:
333333
--sqlnullstr Adds a Null{{ENUM}} type for marshalling a nullable string value to sql. If sqlnullint is specified too, it will be Null{{ENUM}}Str (default: false)
334334
--template value, -t value [ --template value, -t value ] Additional template file(s) to generate enums. Use more than one flag for more files. Templates will be executed in alphabetical order.
335335
--alias value, -a value [ --alias value, -a value ] Adds or replaces aliases for a non alphanumeric value that needs to be accounted for. [Format should be "key:value,key2:value2", or specify multiple entries, or both!]
336+
--initialism value [ --initialism value ] Initialism(s) to keep fully uppercased in generated const names (e.g., HTTP,URL,ID). Repeatable.
336337
--mustparse Adds a Must version of the Parse that will panic on failure. (default: false)
337338
--forcelower Forces a camel cased comment to generate lowercased names. (default: false)
338339
--forceupper Forces a camel cased comment to generate uppercased names. (default: false)
@@ -344,6 +345,23 @@ GLOBAL OPTIONS:
344345
--version, -v print the version
345346
```
346347
348+
### Initialism notes
349+
350+
- `--initialism` affects generated const identifiers only. It does not modify enum string values.
351+
- `--forcelower` and `--forceupper` control enum string values; they are separate from `--initialism`.
352+
- Initialism rewriting runs after `--alias` replacements and after snake_case to CamelCase conversion.
353+
- With `--nocamel`, initialisms in underscore-separated segments may not be rewritten because CamelCase conversion is skipped.
354+
- Rewriting currently runs on the full identifier (including prefix/type-derived segments), not only on the enum value segment.
355+
356+
Example:
357+
358+
```go
359+
// ENUM(created)
360+
type UserId int
361+
```
362+
363+
With `--initialism ID`, the const becomes `UserIDCreated` (the `Id` in the type-derived prefix is rewritten too).
364+
347365
### Syntax
348366
349367
The parser looks for comments on your type defs and parse the enum declarations from it.

0 commit comments

Comments
 (0)