1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838
|
package interp
import (
"bytes"
"errors"
"fmt"
"io"
"math/big"
"reflect"
"time"
"github.com/mitchellh/copystructure"
"github.com/wader/fq/internal/bitioex"
"github.com/wader/fq/internal/gojqex"
"github.com/wader/fq/internal/ioex"
"github.com/wader/fq/internal/mapstruct"
"github.com/wader/fq/pkg/bitio"
"github.com/wader/fq/pkg/decode"
"github.com/wader/fq/pkg/scalar"
"github.com/wader/gojq"
)
func init() {
RegisterFunc0("_registry", (*Interp)._registry)
RegisterFunc1("_tovalue", (*Interp)._toValue)
RegisterFunc2("_decode", (*Interp)._decode)
}
// TODO: redo/rename
// used by _isDecodeValue
type DecodeValue interface {
Value
ToBinary
DecodeValue() *decode.Value
}
func (i *Interp) _registry(c any) any {
uniqueFormats := map[string]*decode.Format{}
groups := map[string]any{}
formats := map[string]any{}
for _, g := range i.Registry.Groups() {
var group []any
for _, f := range g.Formats {
group = append(group, f.Name)
if _, ok := uniqueFormats[f.Name]; ok {
continue
}
uniqueFormats[f.Name] = f
}
groups[g.Name] = group
}
for _, f := range uniqueFormats {
vf := map[string]any{
"name": f.Name,
"description": f.Description,
"probe_order": f.ProbeOrder,
"root_name": f.RootName,
"root_array": f.RootArray,
"skip_decode_function": f.SkipDecodeFunction,
}
var dependenciesVs []any
for _, d := range f.Dependencies {
var dNamesVs []any
for _, g := range d.Groups {
dNamesVs = append(dNamesVs, g.Name)
}
dependenciesVs = append(dependenciesVs, dNamesVs)
}
if len(dependenciesVs) > 0 {
vf["dependencies"] = dependenciesVs
}
var groupsVs []any
for _, g := range f.Groups {
groupsVs = append(groupsVs, g.Name)
}
if len(groupsVs) > 0 {
vf["groups"] = groupsVs
}
if f.DefaultInArg != nil {
doc := map[string]any{}
st := reflect.TypeOf(f.DefaultInArg)
for i := 0; i < st.NumField(); i++ {
f := st.Field(i)
if v, ok := f.Tag.Lookup("doc"); ok {
doc[mapstruct.CamelToSnake(f.Name)] = v
}
}
vf["decode_in_arg_doc"] = doc
args, err := mapstruct.ToMap(f.DefaultInArg)
if err != nil {
return err
}
// filter out internal field without documentation
for k := range args {
if _, ok := doc[k]; !ok {
delete(args, k)
}
}
vf["decode_in_arg"] = gojqex.Normalize(args)
}
if f.Functions != nil {
var ss []any
for _, f := range f.Functions {
ss = append(ss, f)
}
vf["functions"] = ss
}
formats[f.Name] = vf
}
var files []any
for _, fs := range i.Registry.FSs {
ventries := []any{}
entries, err := fs.ReadDir(".")
if err != nil {
return err
}
for _, e := range entries {
f, err := fs.Open(e.Name())
if err != nil {
return err
}
b, err := io.ReadAll(f)
if err != nil {
return err
}
ventries = append(ventries, map[string]any{
"name": e.Name(),
"data": string(b),
})
}
files = append(files, ventries)
}
return map[string]any{
"groups": groups,
"formats": formats,
"files": files,
}
}
func (i *Interp) _toValue(c any, om map[string]any) any {
opts, err := OptionsFromValue(om)
if err != nil {
return err
}
v, err := toValue(func() (*Options, error) { return opts, nil }, c)
if err != nil {
return err
}
return v
}
type decodeOpts struct {
Force bool
Progress string
Remain map[string]any `mapstruct:",remain"`
}
func (i *Interp) _decode(c any, format string, opts decodeOpts) any {
var filename string
// TODO: progress hack
// would be nice to move all progress code into decode but it might be
// tricky to keep track of absolute positions in the underlying readers
// when it uses BitBuf slices, maybe only in Pos()?
if bbf, ok := c.(*openFile); ok {
filename = bbf.filename
if opts.Progress != "" {
evalProgress := func(c any) {
// {approx_read_bytes: 123, total_size: 123} | opts.Progress
_, _ = i.EvalFuncValues(
i.EvalInstance.Ctx,
c,
opts.Progress,
nil,
EvalOpts{output: ioex.DiscardCtxWriter{Ctx: i.EvalInstance.Ctx}},
)
}
lastProgress := time.Now()
bbf.progressFn = func(approxReadBytes, totalSize int64) {
// make sure to not call too often as it's quite expensive
n := time.Now()
if n.Sub(lastProgress) < 200*time.Millisecond {
return
}
lastProgress = n
evalProgress(
map[string]any{
"approx_read_bytes": approxReadBytes,
"total_size": totalSize,
},
)
}
// when done decoding, tell progress function were done and disable it
defer func() {
bbf.progressFn = nil
evalProgress(nil)
}()
}
}
bv, err := toBinary(c)
if err != nil {
return err
}
formatName, err := toString(format)
if err != nil {
return err
}
decodeGroup, err := i.Registry.Group(formatName)
if err != nil {
return err
}
dv, formatOut, err := decode.Decode(i.EvalInstance.Ctx, bv.br, decodeGroup,
decode.Options{
IsRoot: true,
FillGaps: true,
Force: opts.Force,
Range: bv.r,
Description: filename,
ParseOptsFn: func(init any) any {
v, err := copystructure.Copy(init)
if err != nil {
return nil
}
if len(opts.Remain) > 0 {
if err := mapstruct.ToStruct(opts.Remain, &v); err != nil {
// TODO: currently ignores failed struct mappings
return nil
}
}
// nil if same as init
if reflect.DeepEqual(init, v) {
return nil
}
return v
},
},
)
if dv == nil {
var decodeFormatsErr decode.FormatsError
if errors.As(err, &decodeFormatsErr) {
var vs []any
for _, fe := range decodeFormatsErr.Errs {
vs = append(vs, fe.Value())
}
return valueError{vs}
}
return valueError{err}
}
var formatOutMap any
if formatOut != nil {
formatOutMap, err = mapstruct.ToMap(formatOut)
if err != nil {
return err
}
}
return makeDecodeValueOut(dv, decodeValueValue, formatOutMap)
}
func valueOrFallbackKey(name string, baseKey func(name string) any, valueHas func(key any) any, valueKey func(name string) any) any {
v := valueHas(name)
if b, ok := v.(bool); ok && b {
return valueKey(name)
}
return baseKey(name)
}
func valueOrFallbackHas(key any, baseHas func(key any) any, valueHas func(key any) any) any {
v := valueHas(key)
if b, ok := v.(bool); ok && !b {
return baseHas(key)
}
return v
}
// TODO: make more efficient somehow? shallow values but might be hard
// when things like tovalue.key should behave like a jq value and not a decode value etc
func toValue(optsFn func() (*Options, error), v any) (any, error) {
return gojqex.ToGoJQValueFn(v, func(v any) (any, error) {
switch v := v.(type) {
case JQValueEx:
if optsFn == nil {
return v.JQValueToGoJQ(), nil
}
return v.JQValueToGoJQEx(optsFn), nil
case gojq.JQValue:
return v.JQValueToGoJQ(), nil
default:
return v, nil
}
})
}
type decodeValueKind int
const (
decodeValueValue decodeValueKind = iota
decodeValueActual
decodeValueSym
)
func makeDecodeValue(dv *decode.Value, kind decodeValueKind) any {
return makeDecodeValueOut(dv, kind, nil)
}
func makeDecodeValueOut(dv *decode.Value, kind decodeValueKind, out any) any {
switch vv := dv.V.(type) {
case *decode.Compound:
if vv.IsArray {
return NewArrayDecodeValue(dv, out, vv)
}
return NewStructDecodeValue(dv, out, vv)
case scalar.Scalarable:
// TODO: rethink value/actual/sym handling
var vvv any
switch kind {
case decodeValueValue:
vvv = vv.ScalarValue()
case decodeValueActual:
vvv = vv.ScalarActual()
case decodeValueSym:
vvv = vv.ScalarSym()
}
switch vvv := vvv.(type) {
case bitio.ReaderAtSeeker:
// is lazy so that in situations where the decode value is only used to
// create another binary we don't have to read and create a string, ex:
// .unknown0 | tobytes[1:] | ...
return decodeValue{
JQValue: &gojqex.Lazy{
Type: "string",
IsScalar: true,
Fn: func() (gojq.JQValue, error) {
buf := &bytes.Buffer{}
vvvC, err := bitio.CloneReader(vvv)
if err != nil {
return nil, err
}
if _, err := bitioex.CopyBits(buf, vvvC); err != nil {
return nil, err
}
return gojqex.String([]rune(buf.String())), nil
},
},
decodeValueBase: decodeValueBase{dv: dv},
isRaw: true,
}
case bool:
return decodeValue{
JQValue: gojqex.Boolean(vvv),
decodeValueBase: decodeValueBase{dv: dv},
}
case int:
return decodeValue{
JQValue: gojqex.Number{V: vvv},
decodeValueBase: decodeValueBase{dv: dv},
}
case int64:
return decodeValue{
JQValue: gojqex.Number{V: big.NewInt(vvv)},
decodeValueBase: decodeValueBase{dv: dv},
}
case uint64:
return decodeValue{
JQValue: gojqex.Number{V: new(big.Int).SetUint64(vvv)},
decodeValueBase: decodeValueBase{dv: dv},
}
case float64:
return decodeValue{
JQValue: gojqex.Number{V: vvv},
decodeValueBase: decodeValueBase{dv: dv},
}
case string:
return decodeValue{
JQValue: gojqex.String(vvv),
decodeValueBase: decodeValueBase{dv: dv},
}
case []any:
return decodeValue{
JQValue: gojqex.Array(vvv),
decodeValueBase: decodeValueBase{dv: dv},
}
case map[string]any:
return decodeValue{
JQValue: gojqex.Object(vvv),
decodeValueBase: decodeValueBase{dv: dv},
}
case nil:
return decodeValue{
JQValue: gojqex.Null{},
decodeValueBase: decodeValueBase{dv: dv},
}
case *big.Int:
return decodeValue{
JQValue: gojqex.Number{V: vvv},
decodeValueBase: decodeValueBase{dv: dv},
}
case Binary:
return vvv
default:
panic(fmt.Sprintf("unreachable vv %#+v", vvv))
}
default:
panic(fmt.Sprintf("unreachable dv %#+v", dv))
}
}
type decodeValueBase struct {
dv *decode.Value
out any
}
func (dvb decodeValueBase) DecodeValue() *decode.Value {
return dvb.dv
}
func (dvb decodeValueBase) Display(w io.Writer, opts *Options) error { return dump(dvb.dv, w, opts) }
func (dvb decodeValueBase) ToBinary() (Binary, error) {
if s, ok := dvb.dv.V.(scalar.Scalarable); ok && s.ScalarFlags().IsSynthetic() {
return Binary{}, fmt.Errorf("synthetic value can't be a binary")
}
return Binary{br: dvb.dv.RootReader, r: dvb.dv.InnerRange(), unit: 8}, nil
}
func (decodeValueBase) ExtType() string { return "decode_value" }
func (dvb decodeValueBase) ExtKeys() []string {
return []string{
"_actual",
"_bits",
"_buffer_root",
"_bytes",
"_description",
"_error",
"_format_root",
"_format",
"_gap",
"_index",
"_len",
"_name",
"_out",
"_parent",
"_path",
"_root",
"_start",
"_stop",
"_sym",
}
}
func (dvb decodeValueBase) JQValueHas(key any) any {
name, ok := key.(string)
if !ok {
return false
}
switch name {
case "_actual",
"_bits",
"_buffer_root",
"_bytes",
"_description",
"_error",
"_format_root",
"_format",
"_gap",
"_index",
"_len",
"_name",
"_out",
"_parent",
"_path",
"_root",
"_start",
"_stop",
"_sym":
return true
}
return false
}
func (dvb decodeValueBase) JQValueKey(name string) any {
dv := dvb.dv
switch name {
case "_actual":
switch dv.V.(type) {
case scalar.Scalarable:
return makeDecodeValue(dv, decodeValueActual)
default:
return nil
}
case "_bits":
if s, ok := dv.V.(scalar.Scalarable); ok && s.ScalarFlags().IsSynthetic() {
return nil
}
return Binary{
br: dv.RootReader,
r: dv.Range,
unit: 1,
}
case "_buffer_root":
// TODO: rename?
return makeDecodeValue(dv.BufferRoot(), decodeValueValue)
case "_bytes":
if s, ok := dv.V.(scalar.Scalarable); ok && s.ScalarFlags().IsSynthetic() {
return nil
}
return Binary{
br: dv.RootReader,
r: dv.Range,
unit: 8,
}
case "_description":
switch vv := dv.V.(type) {
case *decode.Compound:
if vv.Description == "" {
return nil
}
return vv.Description
case scalar.Scalarable:
desc := vv.ScalarDescription()
if desc == "" {
return nil
}
return desc
default:
return nil
}
case "_format_root":
// TODO: rename?
return makeDecodeValue(dv.FormatRoot(), decodeValueValue)
case "_gap":
switch vv := dv.V.(type) {
case scalar.Scalarable:
return vv.ScalarFlags().IsGap()
default:
return false
}
case "_len":
return big.NewInt(dv.Range.Len)
case "_name":
return dv.Name
case "_parent":
if dv.Parent == nil {
return nil
}
return makeDecodeValue(dv.Parent, decodeValueValue)
case "_path":
return valuePath(dv)
case "_root":
return makeDecodeValue(dv.Root(), decodeValueValue)
case "_start":
return big.NewInt(dv.Range.Start)
case "_stop":
return big.NewInt(dv.Range.Stop())
case "_sym":
switch dv.V.(type) {
case scalar.Scalarable:
return makeDecodeValue(dv, decodeValueSym)
default:
return nil
}
case "_error":
var formatErr decode.FormatError
if errors.As(dv.Err, &formatErr) {
return formatErr.Value()
}
return nil
case "_format":
if dv.Format != nil {
return dv.Format.Name
}
return nil
case "_out":
return dvb.out
case "_index":
if dv.Index != -1 {
return dv.Index
}
}
return nil
}
var _ DecodeValue = decodeValue{}
type decodeValue struct {
gojq.JQValue
decodeValueBase
isRaw bool
}
func (v decodeValue) JQValueKey(name string) any {
return valueOrFallbackKey(name, v.decodeValueBase.JQValueKey, v.JQValue.JQValueHas, v.JQValue.JQValueKey)
}
func (v decodeValue) JQValueHas(key any) any {
return valueOrFallbackHas(key, v.decodeValueBase.JQValueHas, v.JQValue.JQValueHas)
}
func (v decodeValue) JQValueToGoJQEx(optsFn func() (*Options, error)) any {
if !v.isRaw {
return v.JQValueToGoJQ()
}
if s, ok := v.dv.V.(scalar.Scalarable); ok && !s.ScalarFlags().IsSynthetic() {
bv, err := v.ToBinary()
if err != nil {
return err
}
return bv.JQValueToGoJQEx(optsFn)
}
return v.JQValueToGoJQ()
}
// decode value array
var _ DecodeValue = ArrayDecodeValue{}
type ArrayDecodeValue struct {
gojqex.Base
decodeValueBase
*decode.Compound
}
func NewArrayDecodeValue(dv *decode.Value, out any, c *decode.Compound) ArrayDecodeValue {
return ArrayDecodeValue{
decodeValueBase: decodeValueBase{dv: dv, out: out},
Base: gojqex.Base{Typ: gojq.JQTypeArray},
Compound: c,
}
}
func (v ArrayDecodeValue) JQValueKey(name string) any {
return valueOrFallbackKey(name, v.decodeValueBase.JQValueKey, v.Base.JQValueHas, v.Base.JQValueKey)
}
func (v ArrayDecodeValue) JQValueSliceLen() any { return len(v.Compound.Children) }
func (v ArrayDecodeValue) JQValueLength() any { return len(v.Compound.Children) }
func (v ArrayDecodeValue) JQValueIndex(index int) any {
// -1 outside after string, -2 outside before string
if index < 0 {
return nil
}
return makeDecodeValue((v.Compound.Children)[index], decodeValueValue)
}
func (v ArrayDecodeValue) JQValueSlice(start int, end int) any {
vs := make([]any, end-start)
for i, e := range (v.Compound.Children)[start:end] {
vs[i] = makeDecodeValue(e, decodeValueValue)
}
return vs
}
func (v ArrayDecodeValue) JQValueEach() any {
props := make([]gojq.PathValue, len(v.Compound.Children))
for i, f := range v.Compound.Children {
props[i] = gojq.PathValue{Path: i, Value: makeDecodeValue(f, decodeValueValue)}
}
return props
}
func (v ArrayDecodeValue) JQValueKeys() any {
vs := make([]any, len(v.Compound.Children))
for i := range v.Compound.Children {
vs[i] = i
}
return vs
}
func (v ArrayDecodeValue) JQValueHas(key any) any {
return valueOrFallbackHas(
key,
v.decodeValueBase.JQValueHas,
func(key any) any {
intKey, ok := key.(int)
if !ok {
return gojqex.HasKeyTypeError{L: gojq.JQTypeArray, R: fmt.Sprintf("%v", key)}
}
return intKey >= 0 && intKey < len(v.Compound.Children)
})
}
func (v ArrayDecodeValue) JQValueToGoJQEx(optsFn func() (*Options, error)) any {
opts, err := optsFn()
if err != nil {
return err
}
vs := make([]any, 0, len(v.Compound.Children))
for _, f := range v.Compound.Children {
switch s := f.V.(type) {
case scalar.Scalarable:
if s.ScalarFlags().IsGap() && opts.SkipGaps {
// skip, note for arrays this will affect indexes
continue
}
}
vs = append(vs, makeDecodeValue(f, decodeValueValue))
}
return vs
}
func (v ArrayDecodeValue) JQValueToGoJQ() any {
return v.JQValueToGoJQEx(func() (*Options, error) { return &Options{}, nil })
}
// decode value struct
var _ DecodeValue = StructDecodeValue{}
type StructDecodeValue struct {
gojqex.Base
decodeValueBase
*decode.Compound
}
func NewStructDecodeValue(dv *decode.Value, out any, c *decode.Compound) StructDecodeValue {
return StructDecodeValue{
decodeValueBase: decodeValueBase{dv: dv, out: out},
Base: gojqex.Base{Typ: gojq.JQTypeObject},
Compound: c,
}
}
func (v StructDecodeValue) JQValueLength() any { return len(v.Compound.Children) }
func (v StructDecodeValue) JQValueSliceLen() any { return len(v.Compound.Children) }
func (v StructDecodeValue) JQValueKey(name string) any {
return valueOrFallbackKey(
name,
v.decodeValueBase.JQValueKey,
func(key any) any {
stringKey, ok := key.(string)
if !ok {
return false
}
if v.Compound.ByName != nil {
if _, ok := v.Compound.ByName[stringKey]; ok {
return true
}
}
return false
},
func(name string) any {
if v.Compound.ByName != nil {
if f, ok := v.Compound.ByName[name]; ok {
return makeDecodeValue(f, decodeValueValue)
}
}
return nil
},
)
}
func (v StructDecodeValue) JQValueEach() any {
props := make([]gojq.PathValue, len(v.Compound.Children))
for i, f := range v.Compound.Children {
props[i] = gojq.PathValue{Path: f.Name, Value: makeDecodeValue(f, decodeValueValue)}
}
return props
}
func (v StructDecodeValue) JQValueKeys() any {
vs := make([]any, len(v.Compound.Children))
for i, f := range v.Compound.Children {
vs[i] = f.Name
}
return vs
}
func (v StructDecodeValue) JQValueHas(key any) any {
return valueOrFallbackHas(
key,
v.decodeValueBase.JQValueHas,
func(key any) any {
stringKey, ok := key.(string)
if !ok {
return gojqex.HasKeyTypeError{L: gojq.JQTypeObject, R: fmt.Sprintf("%v", key)}
}
if v.Compound.ByName != nil {
if _, ok := v.Compound.ByName[stringKey]; ok {
return true
}
}
return false
},
)
}
func (v StructDecodeValue) JQValueToGoJQEx(optsFn func() (*Options, error)) any {
opts, err := optsFn()
if err != nil {
return err
}
vm := make(map[string]any, len(v.Compound.Children))
for _, f := range v.Compound.Children {
switch s := f.V.(type) {
case scalar.Scalarable:
if s.ScalarFlags().IsGap() && opts.SkipGaps {
continue
}
}
vm[f.Name] = makeDecodeValue(f, decodeValueValue)
}
return vm
}
func (v StructDecodeValue) JQValueToGoJQ() any {
return v.JQValueToGoJQEx(func() (*Options, error) { return &Options{}, nil })
}
|