Skip to content

Commit 06559fd

Browse files
committed
Force all booleans to be explicit
1 parent 057b490 commit 06559fd

File tree

5 files changed

+176
-223
lines changed

5 files changed

+176
-223
lines changed

gen/gotpl/domain.qtpl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,16 @@ const (
5757
// parameters:{% for _, p := range c.Parameters %}{% if p.Optional %}{% continue %}{% endif %}
5858
// {%s= ParamDesc(p) %}{% if p.Optional %} (optional){% endif %}{% endfor %}{% endif %}
5959
func {%s= cmdName %}({%s= ParamList(c, d, domains, false) %}) *{%s= typ %}{
60-
return &{%s= typ %}{{% for _, t := range c.Parameters %}{% if !t.Optional %}
61-
{%s= GoName(t, false) %}: {%s= GoName(t, true) %},{% endif %}{% endfor %}
60+
return &{%s= typ %}{{% for _, t := range c.Parameters %}{% if !t.Optional || t.Type == pdl.TypeBoolean %}{% code
61+
val := GoName(t, true)
62+
if t.Type == pdl.TypeBoolean && t.Optional {
63+
val = "false"
64+
if defaultTrueRE.MatchString(t.Description) {
65+
val = "true"
66+
}
67+
}
68+
%}
69+
{%s= GoName(t, false) %}: {%s= val %},{% endif %}{% endfor %}
6270
}
6371
}
6472
{% endfunc %}

0 commit comments

Comments
 (0)