aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-20 22:30:32 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-20 22:30:32 +0200
commit76f43cc7817fafed2485ac975426eb2e97ea9986 (patch)
tree16629e6bceff4eb36f40b6f3ac2c0e8dcbfa9691
parent62504dda1527490cb49e56dd9840031479d258f0 (diff)
docs: render enum args as type(values) in the generated catalogue
-rw-r--r--docs/PROTOCOL.md26
-rw-r--r--scripts/gen_protocol.c19
2 files changed, 23 insertions, 22 deletions
diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md
index 5aa4ff6..f24e917 100644
--- a/docs/PROTOCOL.md
+++ b/docs/PROTOCOL.md
@@ -648,24 +648,24 @@ the recipient and subject without sending or updating anything.
## Command catalogue (generated)
Generated by `make gen-protocol` from the command tables; do not edit by hand.
-Args: `name:type[!][=default][ enum a\|b]`, `!` = required.
+Args: `name:type(values)[!][=default]`, `!` = required.
| Command | Permission | Org | Mutating | Dry run | Args |
|---|---|---|---|---|---|
| `health` | public | no | no | no | — |
| `meta` | public | no | no | no | — |
-| `session.open` | public | no | no | no | `method:enum! enum password\|token`, `username:string`, `password:string`, `token:string` |
+| `session.open` | public | no | no | no | `method:enum(password\|token)!`, `username:string`, `password:string`, `token:string` |
| `session.close` | viewer | no | no | no | — |
| `session.whoami` | viewer | no | no | no | — |
| `session.list_orgs` | viewer | no | no | no | — |
| `session.use_org` | viewer | no | no | no | `org:int!` |
-| `org.create` | viewer | no | yes | yes | `name:string!`, `org_nr:string`, `fiscal_year_start_month:int=1`, `moms_period:enum=month enum month\|quarter\|year`, `framework:enum=K2 enum K2\|K3` |
+| `org.create` | viewer | no | yes | yes | `name:string!`, `org_nr:string`, `fiscal_year_start_month:int=1`, `moms_period:enum(month\|quarter\|year)=month`, `framework:enum(K2\|K3)=K2` |
| `org.list` | viewer | no | no | no | — |
| `org.get` | viewer | yes | no | no | — |
-| `org.update` | owner | yes | yes | yes | `name:string`, `org_nr:string`, `vat_nr:string`, `address:string`, `postal_code:string`, `city:string`, `country:string`, `email:string`, `phone:string`, `moms_period:enum enum month\|quarter\|year`, `framework:enum enum K2\|K3`, `description:string`, `fiscal_year_start_month:int`, `shares:int` |
+| `org.update` | owner | yes | yes | yes | `name:string`, `org_nr:string`, `vat_nr:string`, `address:string`, `postal_code:string`, `city:string`, `country:string`, `email:string`, `phone:string`, `moms_period:enum(month\|quarter\|year)`, `framework:enum(K2\|K3)`, `description:string`, `fiscal_year_start_month:int`, `shares:int` |
| `org.member_list` | viewer | yes | no | no | — |
-| `org.member_add` | owner | yes | yes | yes | `username:string!`, `role:enum! enum owner\|bookkeeper\|viewer` |
-| `org.member_set_role` | owner | yes | yes | yes | `username:string!`, `role:enum! enum owner\|bookkeeper\|viewer` |
+| `org.member_add` | owner | yes | yes | yes | `username:string!`, `role:enum(owner\|bookkeeper\|viewer)!` |
+| `org.member_set_role` | owner | yes | yes | yes | `username:string!`, `role:enum(owner\|bookkeeper\|viewer)!` |
| `org.member_remove` | owner | yes | yes | yes | `username:string!` |
| `board.list` | viewer | yes | no | no | — |
| `board.add` | owner | yes | yes | yes | `name:string!`, `title:string=Styrelseledamot` |
@@ -683,7 +683,7 @@ Args: `name:type[!][=default][ enum a\|b]`, `!` = required.
| `backup.snapshot` | admin | no | yes | no | `dest:string` |
| `account.list` | viewer | yes | no | no | `active_only:bool` |
| `account.get` | viewer | yes | no | no | `id:int`, `number:string` |
-| `account.create` | bookkeeper | yes | yes | yes | `number:string!`, `name:string!`, `type:enum! enum asset\|liability\|equity\|revenue\|expense`, `sru_code:string`, `vat_code:string` |
+| `account.create` | bookkeeper | yes | yes | yes | `number:string!`, `name:string!`, `type:enum(asset\|liability\|equity\|revenue\|expense)!`, `sru_code:string`, `vat_code:string` |
| `account.update` | bookkeeper | yes | yes | yes | `id:int!`, `name:string`, `sru_code:string`, `vat_code:string`, `active:bool` |
| `fiscal_year.list` | viewer | yes | no | no | — |
| `fiscal_year.get` | viewer | yes | no | no | `id:int` |
@@ -700,13 +700,13 @@ Args: `name:type[!][=default][ enum a\|b]`, `!` = required.
| `bokslut.post` | bookkeeper | yes | yes | yes | `fiscal_year:int`, `entries:json`, `periodiseringsfond_ore:int`, `tax_rate:json=20.6`, `dispose:bool=true`, `date:date` |
| `settings.get` | viewer | yes | no | no | — |
| `settings.set` | bookkeeper | yes | yes | yes | `key:string!`, `value:string` |
-| `bank.import` | bookkeeper | yes | yes | yes | `format:enum! enum seb`, `content_base64:string`, `path:string`, `account:string` |
-| `bank.list` | viewer | yes | no | no | `status:enum=all enum all\|unmatched\|matched`, `from:date`, `to:date`, `account:string`, `limit:int=200` |
+| `bank.import` | bookkeeper | yes | yes | yes | `format:enum(seb)!`, `content_base64:string`, `path:string`, `account:string` |
+| `bank.list` | viewer | yes | no | no | `status:enum(all\|unmatched\|matched)=all`, `from:date`, `to:date`, `account:string`, `limit:int=200` |
| `bank.match` | bookkeeper | yes | yes | yes | `transaction_id:int!`, `voucher_id:int!` |
| `bank.unmatch` | bookkeeper | yes | yes | yes | `transaction_id:int!`, `voucher_id:int!` |
-| `report.rule_list` | viewer | yes | no | no | `report:enum enum vat` |
-| `report.rule_create` | owner | yes | yes | yes | `report:enum! enum vat`, `box:string!`, `match_type:enum! enum account\|range\|type`, `pattern:string!`, `sign:int=1`, `sort_order:int=0` |
-| `report.rule_update` | owner | yes | yes | yes | `id:int!`, `box:string`, `match_type:enum enum account\|range\|type`, `pattern:string`, `sign:int`, `sort_order:int` |
+| `report.rule_list` | viewer | yes | no | no | `report:enum(vat)` |
+| `report.rule_create` | owner | yes | yes | yes | `report:enum(vat)!`, `box:string!`, `match_type:enum(account\|range\|type)!`, `pattern:string!`, `sign:int=1`, `sort_order:int=0` |
+| `report.rule_update` | owner | yes | yes | yes | `id:int!`, `box:string`, `match_type:enum(account\|range\|type)`, `pattern:string`, `sign:int`, `sort_order:int` |
| `report.rule_delete` | owner | yes | yes | yes | `id:int!` |
| `template.list` | viewer | yes | no | no | `active_only:bool` |
| `template.get` | viewer | yes | no | no | `id:int`, `name:string` |
@@ -738,7 +738,7 @@ Args: `name:type[!][=default][ enum a\|b]`, `!` = required.
| `invoice.preview` | viewer | yes | no | no | `customer_id:int!`, `invoice_date:date!`, `due_date:date!`, `delivery_date:string`, `your_ref:string`, `our_ref:string`, `notes:string`, `rows:json!` |
| `invoice.issue` | bookkeeper | yes | yes | yes | `customer_id:int!`, `invoice_date:date!`, `due_date:date!`, `delivery_date:string`, `your_ref:string`, `our_ref:string`, `notes:string`, `rows:json!` |
| `invoice.get` | viewer | yes | no | no | `id:int!` |
-| `invoice.list` | viewer | yes | no | no | `customer_id:int`, `status:enum enum issued\|credited`, `limit:int=200` |
+| `invoice.list` | viewer | yes | no | no | `customer_id:int`, `status:enum(issued\|credited)`, `limit:int=200` |
| `invoice.pdf` | viewer | yes | no | no | `id:int!` |
| `invoice.send` | bookkeeper | yes | yes | yes | `id:int!`, `to:string` |
<!-- generated:commands end -->
diff --git a/scripts/gen_protocol.c b/scripts/gen_protocol.c
index b39bb7d..6746973 100644
--- a/scripts/gen_protocol.c
+++ b/scripts/gen_protocol.c
@@ -66,23 +66,24 @@ static void render_args(struct buf *b, yyjson_val *args)
buf_cell(b, jstr(a, "name"));
buf_puts(b, ":");
buf_cell(b, jstr(a, "type"));
- if (jbool(a, "required"))
- buf_puts(b, "!");
- yyjson_val *def = yyjson_obj_get(a, "default");
- if (def) {
- buf_puts(b, "=");
- buf_cell(b, yyjson_get_str(def));
- }
yyjson_val *vals = yyjson_obj_get(a, "values");
if (vals && yyjson_is_arr(vals)) {
size_t vi, vmax;
yyjson_val *v;
- buf_puts(b, " enum ");
+ buf_puts(b, "(");
yyjson_arr_foreach(vals, vi, vmax, v) {
if (vi)
buf_puts(b, "\\|");
buf_cell(b, yyjson_get_str(v));
}
+ buf_puts(b, ")");
+ }
+ if (jbool(a, "required"))
+ buf_puts(b, "!");
+ yyjson_val *def = yyjson_obj_get(a, "default");
+ if (def) {
+ buf_puts(b, "=");
+ buf_cell(b, yyjson_get_str(def));
}
buf_puts(b, "`");
}
@@ -103,7 +104,7 @@ static char *render_block(void)
buf_puts(&b, BEGIN_MARK "\n");
buf_puts(&b, "## Command catalogue (generated)\n\n");
buf_puts(&b, "Generated by `make gen-protocol` from the command tables; do not "
- "edit by hand.\nArgs: `name:type[!][=default][ enum a\\|b]`, `!` = "
+ "edit by hand.\nArgs: `name:type(values)[!][=default]`, `!` = "
"required.\n\n");
buf_puts(&b, "| Command | Permission | Org | Mutating | Dry run | Args |\n");
buf_puts(&b, "|---|---|---|---|---|---|\n");