alef 0.83.0

Opinionated polyglot binding generator for Rust libraries
Documentation
package main{{ "\n\n" }}import (
{% for import in imports %}
  {{- "\t" }}{% if import.alias %}{{ import.alias }} {% endif %}"{{ import.path }}"
{% endfor %}
)

{% for declaration in package_decls %}
{{ declaration }}
{% endfor %}
func main() {
{% for line in setup_lines %}
  {{- "\t" }}{{ line }}
{% endfor %}
{% if client_setup %}
  {{- "\t" }}{{ client_setup }}
{% endif %}
{% if returns_void %}
  {{- "\t" }}err := {{ call_expr }}
{% elif returns_error %}
  {{- "\t" }}{% if expects_error %}_{% else %}{{ result_var }}{% endif %}, err := {{ call_expr }}
{% else %}
  {{- "\t" }}{{ result_var }} := {{ call_expr }}
{% endif %}
{% if expects_error %}
  {{- "\tvar typedError " }}{{ import_alias }}.{{ error_type }}
  {{- "\n\tif errors.As(err, &typedError) {\n\t\tfmt.Fprintf(os.Stderr, \"%T: %v\\n\", typedError, typedError)\n\t}" }}
{% elif returns_error or returns_void %}
  {{- "\tif err != nil {\n\t\tpanic(err)\n\t}" }}
{% endif %}
{% if not returns_void and not expects_error %}
{% if presentation %}
{% for operation in presentation %}
{% if operation.kind == "show" %}
  {{- "\t" }}fmt.Printf("{{ "%v" if operation.display else "%+v" }}\n", {{ operation.expression }})
{% else %}
  {{- "\t" }}for _, {{ operation.item }} := range {{ operation.expression }} {
{% for field in operation.fields %}
  {{- "\t\t" }}fmt.Printf("{{ "%v" if operation.display else "%+v" }}\n", {{ field }})
{% endfor %}
{% if not operation.fields %}
  {{- "\t\t" }}fmt.Printf("{{ "%v" if operation.display else "%+v" }}\n", {{ operation.item }})
{% endif %}
  {{- "\t" }}}
{% endif %}
{% endfor %}
{% else %}
  {{- "\t" }}fmt.Printf("%+v\n", {{ result_var }})
{% endif %}
{% endif %}
}