github.com/aaronlehmann/figtree@v1.0.1/gen-rawoption.go (about) 1 // This file was automatically generated by genny. 2 // Any changes will be lost if this file is regenerated. 3 // see https://github.com/cheekybits/genny 4 5 package figtree 6 7 import ( 8 "encoding/json" 9 "fmt" 10 ) 11 12 type BoolOption struct { 13 Source string 14 Defined bool 15 Value bool 16 } 17 18 func NewBoolOption(dflt bool) BoolOption { 19 return BoolOption{ 20 Source: "default", 21 Defined: true, 22 Value: dflt, 23 } 24 } 25 26 func (o BoolOption) IsDefined() bool { 27 return o.Defined 28 } 29 30 func (o *BoolOption) SetSource(source string) { 31 o.Source = source 32 } 33 34 func (o *BoolOption) GetSource() string { 35 return o.Source 36 } 37 38 func (o BoolOption) GetValue() interface{} { 39 return o.Value 40 } 41 42 // This is useful with kingpin option parser 43 func (o *BoolOption) Set(s string) error { 44 err := convertString(s, &o.Value) 45 if err != nil { 46 return err 47 } 48 o.Source = "override" 49 o.Defined = true 50 return nil 51 } 52 53 // This is useful with survey prompting library 54 func (o *BoolOption) WriteAnswer(name string, value interface{}) error { 55 if v, ok := value.(bool); ok { 56 o.Value = v 57 o.Defined = true 58 o.Source = "prompt" 59 return nil 60 } 61 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 62 } 63 64 func (o *BoolOption) SetValue(v interface{}) error { 65 if val, ok := v.(bool); ok { 66 o.Value = val 67 o.Defined = true 68 return nil 69 } 70 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 71 } 72 73 func (o *BoolOption) UnmarshalYAML(unmarshal func(interface{}) error) error { 74 if err := unmarshal(&o.Value); err != nil { 75 return err 76 } 77 o.Source = "yaml" 78 o.Defined = true 79 return nil 80 } 81 82 func (o *BoolOption) UnmarshalJSON(b []byte) error { 83 if err := json.Unmarshal(b, &o.Value); err != nil { 84 return err 85 } 86 o.Source = "json" 87 o.Defined = true 88 return nil 89 } 90 91 func (o BoolOption) MarshalYAML() (interface{}, error) { 92 if StringifyValue { 93 return o.Value, nil 94 } 95 // need a copy of this struct without the MarshalYAML interface attached 96 return struct { 97 Value bool 98 Source string 99 Defined bool 100 }{ 101 Value: o.Value, 102 Source: o.Source, 103 Defined: o.Defined, 104 }, nil 105 } 106 107 func (o BoolOption) MarshalJSON() ([]byte, error) { 108 if StringifyValue { 109 return json.Marshal(o.Value) 110 } 111 // need a copy of this struct without the MarshalJSON interface attached 112 return json.Marshal(struct { 113 Value bool 114 Source string 115 Defined bool 116 }{ 117 Value: o.Value, 118 Source: o.Source, 119 Defined: o.Defined, 120 }) 121 } 122 123 // String is required for kingpin to generate usage with this datatype 124 func (o BoolOption) String() string { 125 if StringifyValue { 126 return fmt.Sprintf("%v", o.Value) 127 } 128 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 129 } 130 131 type MapBoolOption map[string]BoolOption 132 133 // Set is required for kingpin interfaces to allow command line params 134 // to be set to our map datatype 135 func (o *MapBoolOption) Set(value string) error { 136 parts := stringMapRegex.Split(value, 2) 137 if len(parts) != 2 { 138 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 139 } 140 val := BoolOption{} 141 val.Set(parts[1]) 142 (*o)[parts[0]] = val 143 return nil 144 } 145 146 // IsCumulative is required for kingpin interfaces to allow multiple values 147 // to be set on the data structure. 148 func (o MapBoolOption) IsCumulative() bool { 149 return true 150 } 151 152 // String is required for kingpin to generate usage with this datatype 153 func (o MapBoolOption) String() string { 154 return fmt.Sprintf("%v", map[string]BoolOption(o)) 155 } 156 157 func (o MapBoolOption) Map() map[string]bool { 158 tmp := map[string]bool{} 159 for k, v := range o { 160 tmp[k] = v.Value 161 } 162 return tmp 163 } 164 165 // This is useful with survey prompting library 166 func (o *MapBoolOption) WriteAnswer(name string, value interface{}) error { 167 tmp := BoolOption{} 168 if v, ok := value.(bool); ok { 169 tmp.Value = v 170 tmp.Defined = true 171 tmp.Source = "prompt" 172 (*o)[name] = tmp 173 return nil 174 } 175 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 176 } 177 178 func (o MapBoolOption) IsDefined() bool { 179 // true if the map has any keys 180 if len(o) > 0 { 181 return true 182 } 183 return false 184 } 185 186 type ListBoolOption []BoolOption 187 188 // Set is required for kingpin interfaces to allow command line params 189 // to be set to our map datatype 190 func (o *ListBoolOption) Set(value string) error { 191 val := BoolOption{} 192 val.Set(value) 193 *o = append(*o, val) 194 return nil 195 } 196 197 // This is useful with survey prompting library 198 func (o *ListBoolOption) WriteAnswer(name string, value interface{}) error { 199 tmp := BoolOption{} 200 if v, ok := value.(bool); ok { 201 tmp.Value = v 202 tmp.Defined = true 203 tmp.Source = "prompt" 204 *o = append(*o, tmp) 205 return nil 206 } 207 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 208 } 209 210 // IsCumulative is required for kingpin interfaces to allow multiple values 211 // to be set on the data structure. 212 func (o ListBoolOption) IsCumulative() bool { 213 return true 214 } 215 216 // String is required for kingpin to generate usage with this datatype 217 func (o ListBoolOption) String() string { 218 return fmt.Sprintf("%v", []BoolOption(o)) 219 } 220 221 func (o ListBoolOption) Append(values ...bool) ListBoolOption { 222 results := o 223 for _, val := range values { 224 results = append(results, NewBoolOption(val)) 225 } 226 return results 227 } 228 229 func (o ListBoolOption) Slice() []bool { 230 tmp := []bool{} 231 for _, elem := range o { 232 tmp = append(tmp, elem.Value) 233 } 234 return tmp 235 } 236 237 func (o ListBoolOption) IsDefined() bool { 238 // true if the list is not empty 239 if len(o) > 0 { 240 return true 241 } 242 return false 243 } 244 245 type ByteOption struct { 246 Source string 247 Defined bool 248 Value byte 249 } 250 251 func NewByteOption(dflt byte) ByteOption { 252 return ByteOption{ 253 Source: "default", 254 Defined: true, 255 Value: dflt, 256 } 257 } 258 259 func (o ByteOption) IsDefined() bool { 260 return o.Defined 261 } 262 263 func (o *ByteOption) SetSource(source string) { 264 o.Source = source 265 } 266 267 func (o *ByteOption) GetSource() string { 268 return o.Source 269 } 270 271 func (o ByteOption) GetValue() interface{} { 272 return o.Value 273 } 274 275 // This is useful with kingpin option parser 276 func (o *ByteOption) Set(s string) error { 277 err := convertString(s, &o.Value) 278 if err != nil { 279 return err 280 } 281 o.Source = "override" 282 o.Defined = true 283 return nil 284 } 285 286 // This is useful with survey prompting library 287 func (o *ByteOption) WriteAnswer(name string, value interface{}) error { 288 if v, ok := value.(byte); ok { 289 o.Value = v 290 o.Defined = true 291 o.Source = "prompt" 292 return nil 293 } 294 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 295 } 296 297 func (o *ByteOption) SetValue(v interface{}) error { 298 if val, ok := v.(byte); ok { 299 o.Value = val 300 o.Defined = true 301 return nil 302 } 303 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 304 } 305 306 func (o *ByteOption) UnmarshalYAML(unmarshal func(interface{}) error) error { 307 if err := unmarshal(&o.Value); err != nil { 308 return err 309 } 310 o.Source = "yaml" 311 o.Defined = true 312 return nil 313 } 314 315 func (o *ByteOption) UnmarshalJSON(b []byte) error { 316 if err := json.Unmarshal(b, &o.Value); err != nil { 317 return err 318 } 319 o.Source = "json" 320 o.Defined = true 321 return nil 322 } 323 324 func (o ByteOption) MarshalYAML() (interface{}, error) { 325 if StringifyValue { 326 return o.Value, nil 327 } 328 // need a copy of this struct without the MarshalYAML interface attached 329 return struct { 330 Value byte 331 Source string 332 Defined bool 333 }{ 334 Value: o.Value, 335 Source: o.Source, 336 Defined: o.Defined, 337 }, nil 338 } 339 340 func (o ByteOption) MarshalJSON() ([]byte, error) { 341 if StringifyValue { 342 return json.Marshal(o.Value) 343 } 344 // need a copy of this struct without the MarshalJSON interface attached 345 return json.Marshal(struct { 346 Value byte 347 Source string 348 Defined bool 349 }{ 350 Value: o.Value, 351 Source: o.Source, 352 Defined: o.Defined, 353 }) 354 } 355 356 // String is required for kingpin to generate usage with this datatype 357 func (o ByteOption) String() string { 358 if StringifyValue { 359 return fmt.Sprintf("%v", o.Value) 360 } 361 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 362 } 363 364 type MapByteOption map[string]ByteOption 365 366 // Set is required for kingpin interfaces to allow command line params 367 // to be set to our map datatype 368 func (o *MapByteOption) Set(value string) error { 369 parts := stringMapRegex.Split(value, 2) 370 if len(parts) != 2 { 371 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 372 } 373 val := ByteOption{} 374 val.Set(parts[1]) 375 (*o)[parts[0]] = val 376 return nil 377 } 378 379 // IsCumulative is required for kingpin interfaces to allow multiple values 380 // to be set on the data structure. 381 func (o MapByteOption) IsCumulative() bool { 382 return true 383 } 384 385 // String is required for kingpin to generate usage with this datatype 386 func (o MapByteOption) String() string { 387 return fmt.Sprintf("%v", map[string]ByteOption(o)) 388 } 389 390 func (o MapByteOption) Map() map[string]byte { 391 tmp := map[string]byte{} 392 for k, v := range o { 393 tmp[k] = v.Value 394 } 395 return tmp 396 } 397 398 // This is useful with survey prompting library 399 func (o *MapByteOption) WriteAnswer(name string, value interface{}) error { 400 tmp := ByteOption{} 401 if v, ok := value.(byte); ok { 402 tmp.Value = v 403 tmp.Defined = true 404 tmp.Source = "prompt" 405 (*o)[name] = tmp 406 return nil 407 } 408 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 409 } 410 411 func (o MapByteOption) IsDefined() bool { 412 // true if the map has any keys 413 if len(o) > 0 { 414 return true 415 } 416 return false 417 } 418 419 type ListByteOption []ByteOption 420 421 // Set is required for kingpin interfaces to allow command line params 422 // to be set to our map datatype 423 func (o *ListByteOption) Set(value string) error { 424 val := ByteOption{} 425 val.Set(value) 426 *o = append(*o, val) 427 return nil 428 } 429 430 // This is useful with survey prompting library 431 func (o *ListByteOption) WriteAnswer(name string, value interface{}) error { 432 tmp := ByteOption{} 433 if v, ok := value.(byte); ok { 434 tmp.Value = v 435 tmp.Defined = true 436 tmp.Source = "prompt" 437 *o = append(*o, tmp) 438 return nil 439 } 440 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 441 } 442 443 // IsCumulative is required for kingpin interfaces to allow multiple values 444 // to be set on the data structure. 445 func (o ListByteOption) IsCumulative() bool { 446 return true 447 } 448 449 // String is required for kingpin to generate usage with this datatype 450 func (o ListByteOption) String() string { 451 return fmt.Sprintf("%v", []ByteOption(o)) 452 } 453 454 func (o ListByteOption) Append(values ...byte) ListByteOption { 455 results := o 456 for _, val := range values { 457 results = append(results, NewByteOption(val)) 458 } 459 return results 460 } 461 462 func (o ListByteOption) Slice() []byte { 463 tmp := []byte{} 464 for _, elem := range o { 465 tmp = append(tmp, elem.Value) 466 } 467 return tmp 468 } 469 470 func (o ListByteOption) IsDefined() bool { 471 // true if the list is not empty 472 if len(o) > 0 { 473 return true 474 } 475 return false 476 } 477 478 type Complex128Option struct { 479 Source string 480 Defined bool 481 Value complex128 482 } 483 484 func NewComplex128Option(dflt complex128) Complex128Option { 485 return Complex128Option{ 486 Source: "default", 487 Defined: true, 488 Value: dflt, 489 } 490 } 491 492 func (o Complex128Option) IsDefined() bool { 493 return o.Defined 494 } 495 496 func (o *Complex128Option) SetSource(source string) { 497 o.Source = source 498 } 499 500 func (o *Complex128Option) GetSource() string { 501 return o.Source 502 } 503 504 func (o Complex128Option) GetValue() interface{} { 505 return o.Value 506 } 507 508 // This is useful with kingpin option parser 509 func (o *Complex128Option) Set(s string) error { 510 err := convertString(s, &o.Value) 511 if err != nil { 512 return err 513 } 514 o.Source = "override" 515 o.Defined = true 516 return nil 517 } 518 519 // This is useful with survey prompting library 520 func (o *Complex128Option) WriteAnswer(name string, value interface{}) error { 521 if v, ok := value.(complex128); ok { 522 o.Value = v 523 o.Defined = true 524 o.Source = "prompt" 525 return nil 526 } 527 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 528 } 529 530 func (o *Complex128Option) SetValue(v interface{}) error { 531 if val, ok := v.(complex128); ok { 532 o.Value = val 533 o.Defined = true 534 return nil 535 } 536 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 537 } 538 539 func (o *Complex128Option) UnmarshalYAML(unmarshal func(interface{}) error) error { 540 if err := unmarshal(&o.Value); err != nil { 541 return err 542 } 543 o.Source = "yaml" 544 o.Defined = true 545 return nil 546 } 547 548 func (o *Complex128Option) UnmarshalJSON(b []byte) error { 549 if err := json.Unmarshal(b, &o.Value); err != nil { 550 return err 551 } 552 o.Source = "json" 553 o.Defined = true 554 return nil 555 } 556 557 func (o Complex128Option) MarshalYAML() (interface{}, error) { 558 if StringifyValue { 559 return o.Value, nil 560 } 561 // need a copy of this struct without the MarshalYAML interface attached 562 return struct { 563 Value complex128 564 Source string 565 Defined bool 566 }{ 567 Value: o.Value, 568 Source: o.Source, 569 Defined: o.Defined, 570 }, nil 571 } 572 573 func (o Complex128Option) MarshalJSON() ([]byte, error) { 574 if StringifyValue { 575 return json.Marshal(o.Value) 576 } 577 // need a copy of this struct without the MarshalJSON interface attached 578 return json.Marshal(struct { 579 Value complex128 580 Source string 581 Defined bool 582 }{ 583 Value: o.Value, 584 Source: o.Source, 585 Defined: o.Defined, 586 }) 587 } 588 589 // String is required for kingpin to generate usage with this datatype 590 func (o Complex128Option) String() string { 591 if StringifyValue { 592 return fmt.Sprintf("%v", o.Value) 593 } 594 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 595 } 596 597 type MapComplex128Option map[string]Complex128Option 598 599 // Set is required for kingpin interfaces to allow command line params 600 // to be set to our map datatype 601 func (o *MapComplex128Option) Set(value string) error { 602 parts := stringMapRegex.Split(value, 2) 603 if len(parts) != 2 { 604 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 605 } 606 val := Complex128Option{} 607 val.Set(parts[1]) 608 (*o)[parts[0]] = val 609 return nil 610 } 611 612 // IsCumulative is required for kingpin interfaces to allow multiple values 613 // to be set on the data structure. 614 func (o MapComplex128Option) IsCumulative() bool { 615 return true 616 } 617 618 // String is required for kingpin to generate usage with this datatype 619 func (o MapComplex128Option) String() string { 620 return fmt.Sprintf("%v", map[string]Complex128Option(o)) 621 } 622 623 func (o MapComplex128Option) Map() map[string]complex128 { 624 tmp := map[string]complex128{} 625 for k, v := range o { 626 tmp[k] = v.Value 627 } 628 return tmp 629 } 630 631 // This is useful with survey prompting library 632 func (o *MapComplex128Option) WriteAnswer(name string, value interface{}) error { 633 tmp := Complex128Option{} 634 if v, ok := value.(complex128); ok { 635 tmp.Value = v 636 tmp.Defined = true 637 tmp.Source = "prompt" 638 (*o)[name] = tmp 639 return nil 640 } 641 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 642 } 643 644 func (o MapComplex128Option) IsDefined() bool { 645 // true if the map has any keys 646 if len(o) > 0 { 647 return true 648 } 649 return false 650 } 651 652 type ListComplex128Option []Complex128Option 653 654 // Set is required for kingpin interfaces to allow command line params 655 // to be set to our map datatype 656 func (o *ListComplex128Option) Set(value string) error { 657 val := Complex128Option{} 658 val.Set(value) 659 *o = append(*o, val) 660 return nil 661 } 662 663 // This is useful with survey prompting library 664 func (o *ListComplex128Option) WriteAnswer(name string, value interface{}) error { 665 tmp := Complex128Option{} 666 if v, ok := value.(complex128); ok { 667 tmp.Value = v 668 tmp.Defined = true 669 tmp.Source = "prompt" 670 *o = append(*o, tmp) 671 return nil 672 } 673 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 674 } 675 676 // IsCumulative is required for kingpin interfaces to allow multiple values 677 // to be set on the data structure. 678 func (o ListComplex128Option) IsCumulative() bool { 679 return true 680 } 681 682 // String is required for kingpin to generate usage with this datatype 683 func (o ListComplex128Option) String() string { 684 return fmt.Sprintf("%v", []Complex128Option(o)) 685 } 686 687 func (o ListComplex128Option) Append(values ...complex128) ListComplex128Option { 688 results := o 689 for _, val := range values { 690 results = append(results, NewComplex128Option(val)) 691 } 692 return results 693 } 694 695 func (o ListComplex128Option) Slice() []complex128 { 696 tmp := []complex128{} 697 for _, elem := range o { 698 tmp = append(tmp, elem.Value) 699 } 700 return tmp 701 } 702 703 func (o ListComplex128Option) IsDefined() bool { 704 // true if the list is not empty 705 if len(o) > 0 { 706 return true 707 } 708 return false 709 } 710 711 type Complex64Option struct { 712 Source string 713 Defined bool 714 Value complex64 715 } 716 717 func NewComplex64Option(dflt complex64) Complex64Option { 718 return Complex64Option{ 719 Source: "default", 720 Defined: true, 721 Value: dflt, 722 } 723 } 724 725 func (o Complex64Option) IsDefined() bool { 726 return o.Defined 727 } 728 729 func (o *Complex64Option) SetSource(source string) { 730 o.Source = source 731 } 732 733 func (o *Complex64Option) GetSource() string { 734 return o.Source 735 } 736 737 func (o Complex64Option) GetValue() interface{} { 738 return o.Value 739 } 740 741 // This is useful with kingpin option parser 742 func (o *Complex64Option) Set(s string) error { 743 err := convertString(s, &o.Value) 744 if err != nil { 745 return err 746 } 747 o.Source = "override" 748 o.Defined = true 749 return nil 750 } 751 752 // This is useful with survey prompting library 753 func (o *Complex64Option) WriteAnswer(name string, value interface{}) error { 754 if v, ok := value.(complex64); ok { 755 o.Value = v 756 o.Defined = true 757 o.Source = "prompt" 758 return nil 759 } 760 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 761 } 762 763 func (o *Complex64Option) SetValue(v interface{}) error { 764 if val, ok := v.(complex64); ok { 765 o.Value = val 766 o.Defined = true 767 return nil 768 } 769 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 770 } 771 772 func (o *Complex64Option) UnmarshalYAML(unmarshal func(interface{}) error) error { 773 if err := unmarshal(&o.Value); err != nil { 774 return err 775 } 776 o.Source = "yaml" 777 o.Defined = true 778 return nil 779 } 780 781 func (o *Complex64Option) UnmarshalJSON(b []byte) error { 782 if err := json.Unmarshal(b, &o.Value); err != nil { 783 return err 784 } 785 o.Source = "json" 786 o.Defined = true 787 return nil 788 } 789 790 func (o Complex64Option) MarshalYAML() (interface{}, error) { 791 if StringifyValue { 792 return o.Value, nil 793 } 794 // need a copy of this struct without the MarshalYAML interface attached 795 return struct { 796 Value complex64 797 Source string 798 Defined bool 799 }{ 800 Value: o.Value, 801 Source: o.Source, 802 Defined: o.Defined, 803 }, nil 804 } 805 806 func (o Complex64Option) MarshalJSON() ([]byte, error) { 807 if StringifyValue { 808 return json.Marshal(o.Value) 809 } 810 // need a copy of this struct without the MarshalJSON interface attached 811 return json.Marshal(struct { 812 Value complex64 813 Source string 814 Defined bool 815 }{ 816 Value: o.Value, 817 Source: o.Source, 818 Defined: o.Defined, 819 }) 820 } 821 822 // String is required for kingpin to generate usage with this datatype 823 func (o Complex64Option) String() string { 824 if StringifyValue { 825 return fmt.Sprintf("%v", o.Value) 826 } 827 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 828 } 829 830 type MapComplex64Option map[string]Complex64Option 831 832 // Set is required for kingpin interfaces to allow command line params 833 // to be set to our map datatype 834 func (o *MapComplex64Option) Set(value string) error { 835 parts := stringMapRegex.Split(value, 2) 836 if len(parts) != 2 { 837 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 838 } 839 val := Complex64Option{} 840 val.Set(parts[1]) 841 (*o)[parts[0]] = val 842 return nil 843 } 844 845 // IsCumulative is required for kingpin interfaces to allow multiple values 846 // to be set on the data structure. 847 func (o MapComplex64Option) IsCumulative() bool { 848 return true 849 } 850 851 // String is required for kingpin to generate usage with this datatype 852 func (o MapComplex64Option) String() string { 853 return fmt.Sprintf("%v", map[string]Complex64Option(o)) 854 } 855 856 func (o MapComplex64Option) Map() map[string]complex64 { 857 tmp := map[string]complex64{} 858 for k, v := range o { 859 tmp[k] = v.Value 860 } 861 return tmp 862 } 863 864 // This is useful with survey prompting library 865 func (o *MapComplex64Option) WriteAnswer(name string, value interface{}) error { 866 tmp := Complex64Option{} 867 if v, ok := value.(complex64); ok { 868 tmp.Value = v 869 tmp.Defined = true 870 tmp.Source = "prompt" 871 (*o)[name] = tmp 872 return nil 873 } 874 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 875 } 876 877 func (o MapComplex64Option) IsDefined() bool { 878 // true if the map has any keys 879 if len(o) > 0 { 880 return true 881 } 882 return false 883 } 884 885 type ListComplex64Option []Complex64Option 886 887 // Set is required for kingpin interfaces to allow command line params 888 // to be set to our map datatype 889 func (o *ListComplex64Option) Set(value string) error { 890 val := Complex64Option{} 891 val.Set(value) 892 *o = append(*o, val) 893 return nil 894 } 895 896 // This is useful with survey prompting library 897 func (o *ListComplex64Option) WriteAnswer(name string, value interface{}) error { 898 tmp := Complex64Option{} 899 if v, ok := value.(complex64); ok { 900 tmp.Value = v 901 tmp.Defined = true 902 tmp.Source = "prompt" 903 *o = append(*o, tmp) 904 return nil 905 } 906 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 907 } 908 909 // IsCumulative is required for kingpin interfaces to allow multiple values 910 // to be set on the data structure. 911 func (o ListComplex64Option) IsCumulative() bool { 912 return true 913 } 914 915 // String is required for kingpin to generate usage with this datatype 916 func (o ListComplex64Option) String() string { 917 return fmt.Sprintf("%v", []Complex64Option(o)) 918 } 919 920 func (o ListComplex64Option) Append(values ...complex64) ListComplex64Option { 921 results := o 922 for _, val := range values { 923 results = append(results, NewComplex64Option(val)) 924 } 925 return results 926 } 927 928 func (o ListComplex64Option) Slice() []complex64 { 929 tmp := []complex64{} 930 for _, elem := range o { 931 tmp = append(tmp, elem.Value) 932 } 933 return tmp 934 } 935 936 func (o ListComplex64Option) IsDefined() bool { 937 // true if the list is not empty 938 if len(o) > 0 { 939 return true 940 } 941 return false 942 } 943 944 type ErrorOption struct { 945 Source string 946 Defined bool 947 Value error 948 } 949 950 func NewErrorOption(dflt error) ErrorOption { 951 return ErrorOption{ 952 Source: "default", 953 Defined: true, 954 Value: dflt, 955 } 956 } 957 958 func (o ErrorOption) IsDefined() bool { 959 return o.Defined 960 } 961 962 func (o *ErrorOption) SetSource(source string) { 963 o.Source = source 964 } 965 966 func (o *ErrorOption) GetSource() string { 967 return o.Source 968 } 969 970 func (o ErrorOption) GetValue() interface{} { 971 return o.Value 972 } 973 974 // This is useful with kingpin option parser 975 func (o *ErrorOption) Set(s string) error { 976 err := convertString(s, &o.Value) 977 if err != nil { 978 return err 979 } 980 o.Source = "override" 981 o.Defined = true 982 return nil 983 } 984 985 // This is useful with survey prompting library 986 func (o *ErrorOption) WriteAnswer(name string, value interface{}) error { 987 if v, ok := value.(error); ok { 988 o.Value = v 989 o.Defined = true 990 o.Source = "prompt" 991 return nil 992 } 993 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 994 } 995 996 func (o *ErrorOption) SetValue(v interface{}) error { 997 if val, ok := v.(error); ok { 998 o.Value = val 999 o.Defined = true 1000 return nil 1001 } 1002 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 1003 } 1004 1005 func (o *ErrorOption) UnmarshalYAML(unmarshal func(interface{}) error) error { 1006 if err := unmarshal(&o.Value); err != nil { 1007 return err 1008 } 1009 o.Source = "yaml" 1010 o.Defined = true 1011 return nil 1012 } 1013 1014 func (o *ErrorOption) UnmarshalJSON(b []byte) error { 1015 if err := json.Unmarshal(b, &o.Value); err != nil { 1016 return err 1017 } 1018 o.Source = "json" 1019 o.Defined = true 1020 return nil 1021 } 1022 1023 func (o ErrorOption) MarshalYAML() (interface{}, error) { 1024 if StringifyValue { 1025 return o.Value, nil 1026 } 1027 // need a copy of this struct without the MarshalYAML interface attached 1028 return struct { 1029 Value error 1030 Source string 1031 Defined bool 1032 }{ 1033 Value: o.Value, 1034 Source: o.Source, 1035 Defined: o.Defined, 1036 }, nil 1037 } 1038 1039 func (o ErrorOption) MarshalJSON() ([]byte, error) { 1040 if StringifyValue { 1041 return json.Marshal(o.Value) 1042 } 1043 // need a copy of this struct without the MarshalJSON interface attached 1044 return json.Marshal(struct { 1045 Value error 1046 Source string 1047 Defined bool 1048 }{ 1049 Value: o.Value, 1050 Source: o.Source, 1051 Defined: o.Defined, 1052 }) 1053 } 1054 1055 // String is required for kingpin to generate usage with this datatype 1056 func (o ErrorOption) String() string { 1057 if StringifyValue { 1058 return fmt.Sprintf("%v", o.Value) 1059 } 1060 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 1061 } 1062 1063 type MapErrorOption map[string]ErrorOption 1064 1065 // Set is required for kingpin interfaces to allow command line params 1066 // to be set to our map datatype 1067 func (o *MapErrorOption) Set(value string) error { 1068 parts := stringMapRegex.Split(value, 2) 1069 if len(parts) != 2 { 1070 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 1071 } 1072 val := ErrorOption{} 1073 val.Set(parts[1]) 1074 (*o)[parts[0]] = val 1075 return nil 1076 } 1077 1078 // IsCumulative is required for kingpin interfaces to allow multiple values 1079 // to be set on the data structure. 1080 func (o MapErrorOption) IsCumulative() bool { 1081 return true 1082 } 1083 1084 // String is required for kingpin to generate usage with this datatype 1085 func (o MapErrorOption) String() string { 1086 return fmt.Sprintf("%v", map[string]ErrorOption(o)) 1087 } 1088 1089 func (o MapErrorOption) Map() map[string]error { 1090 tmp := map[string]error{} 1091 for k, v := range o { 1092 tmp[k] = v.Value 1093 } 1094 return tmp 1095 } 1096 1097 // This is useful with survey prompting library 1098 func (o *MapErrorOption) WriteAnswer(name string, value interface{}) error { 1099 tmp := ErrorOption{} 1100 if v, ok := value.(error); ok { 1101 tmp.Value = v 1102 tmp.Defined = true 1103 tmp.Source = "prompt" 1104 (*o)[name] = tmp 1105 return nil 1106 } 1107 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 1108 } 1109 1110 func (o MapErrorOption) IsDefined() bool { 1111 // true if the map has any keys 1112 if len(o) > 0 { 1113 return true 1114 } 1115 return false 1116 } 1117 1118 type ListErrorOption []ErrorOption 1119 1120 // Set is required for kingpin interfaces to allow command line params 1121 // to be set to our map datatype 1122 func (o *ListErrorOption) Set(value string) error { 1123 val := ErrorOption{} 1124 val.Set(value) 1125 *o = append(*o, val) 1126 return nil 1127 } 1128 1129 // This is useful with survey prompting library 1130 func (o *ListErrorOption) WriteAnswer(name string, value interface{}) error { 1131 tmp := ErrorOption{} 1132 if v, ok := value.(error); ok { 1133 tmp.Value = v 1134 tmp.Defined = true 1135 tmp.Source = "prompt" 1136 *o = append(*o, tmp) 1137 return nil 1138 } 1139 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 1140 } 1141 1142 // IsCumulative is required for kingpin interfaces to allow multiple values 1143 // to be set on the data structure. 1144 func (o ListErrorOption) IsCumulative() bool { 1145 return true 1146 } 1147 1148 // String is required for kingpin to generate usage with this datatype 1149 func (o ListErrorOption) String() string { 1150 return fmt.Sprintf("%v", []ErrorOption(o)) 1151 } 1152 1153 func (o ListErrorOption) Append(values ...error) ListErrorOption { 1154 results := o 1155 for _, val := range values { 1156 results = append(results, NewErrorOption(val)) 1157 } 1158 return results 1159 } 1160 1161 func (o ListErrorOption) Slice() []error { 1162 tmp := []error{} 1163 for _, elem := range o { 1164 tmp = append(tmp, elem.Value) 1165 } 1166 return tmp 1167 } 1168 1169 func (o ListErrorOption) IsDefined() bool { 1170 // true if the list is not empty 1171 if len(o) > 0 { 1172 return true 1173 } 1174 return false 1175 } 1176 1177 type Float32Option struct { 1178 Source string 1179 Defined bool 1180 Value float32 1181 } 1182 1183 func NewFloat32Option(dflt float32) Float32Option { 1184 return Float32Option{ 1185 Source: "default", 1186 Defined: true, 1187 Value: dflt, 1188 } 1189 } 1190 1191 func (o Float32Option) IsDefined() bool { 1192 return o.Defined 1193 } 1194 1195 func (o *Float32Option) SetSource(source string) { 1196 o.Source = source 1197 } 1198 1199 func (o *Float32Option) GetSource() string { 1200 return o.Source 1201 } 1202 1203 func (o Float32Option) GetValue() interface{} { 1204 return o.Value 1205 } 1206 1207 // This is useful with kingpin option parser 1208 func (o *Float32Option) Set(s string) error { 1209 err := convertString(s, &o.Value) 1210 if err != nil { 1211 return err 1212 } 1213 o.Source = "override" 1214 o.Defined = true 1215 return nil 1216 } 1217 1218 // This is useful with survey prompting library 1219 func (o *Float32Option) WriteAnswer(name string, value interface{}) error { 1220 if v, ok := value.(float32); ok { 1221 o.Value = v 1222 o.Defined = true 1223 o.Source = "prompt" 1224 return nil 1225 } 1226 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 1227 } 1228 1229 func (o *Float32Option) SetValue(v interface{}) error { 1230 if val, ok := v.(float32); ok { 1231 o.Value = val 1232 o.Defined = true 1233 return nil 1234 } 1235 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 1236 } 1237 1238 func (o *Float32Option) UnmarshalYAML(unmarshal func(interface{}) error) error { 1239 if err := unmarshal(&o.Value); err != nil { 1240 return err 1241 } 1242 o.Source = "yaml" 1243 o.Defined = true 1244 return nil 1245 } 1246 1247 func (o *Float32Option) UnmarshalJSON(b []byte) error { 1248 if err := json.Unmarshal(b, &o.Value); err != nil { 1249 return err 1250 } 1251 o.Source = "json" 1252 o.Defined = true 1253 return nil 1254 } 1255 1256 func (o Float32Option) MarshalYAML() (interface{}, error) { 1257 if StringifyValue { 1258 return o.Value, nil 1259 } 1260 // need a copy of this struct without the MarshalYAML interface attached 1261 return struct { 1262 Value float32 1263 Source string 1264 Defined bool 1265 }{ 1266 Value: o.Value, 1267 Source: o.Source, 1268 Defined: o.Defined, 1269 }, nil 1270 } 1271 1272 func (o Float32Option) MarshalJSON() ([]byte, error) { 1273 if StringifyValue { 1274 return json.Marshal(o.Value) 1275 } 1276 // need a copy of this struct without the MarshalJSON interface attached 1277 return json.Marshal(struct { 1278 Value float32 1279 Source string 1280 Defined bool 1281 }{ 1282 Value: o.Value, 1283 Source: o.Source, 1284 Defined: o.Defined, 1285 }) 1286 } 1287 1288 // String is required for kingpin to generate usage with this datatype 1289 func (o Float32Option) String() string { 1290 if StringifyValue { 1291 return fmt.Sprintf("%v", o.Value) 1292 } 1293 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 1294 } 1295 1296 type MapFloat32Option map[string]Float32Option 1297 1298 // Set is required for kingpin interfaces to allow command line params 1299 // to be set to our map datatype 1300 func (o *MapFloat32Option) Set(value string) error { 1301 parts := stringMapRegex.Split(value, 2) 1302 if len(parts) != 2 { 1303 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 1304 } 1305 val := Float32Option{} 1306 val.Set(parts[1]) 1307 (*o)[parts[0]] = val 1308 return nil 1309 } 1310 1311 // IsCumulative is required for kingpin interfaces to allow multiple values 1312 // to be set on the data structure. 1313 func (o MapFloat32Option) IsCumulative() bool { 1314 return true 1315 } 1316 1317 // String is required for kingpin to generate usage with this datatype 1318 func (o MapFloat32Option) String() string { 1319 return fmt.Sprintf("%v", map[string]Float32Option(o)) 1320 } 1321 1322 func (o MapFloat32Option) Map() map[string]float32 { 1323 tmp := map[string]float32{} 1324 for k, v := range o { 1325 tmp[k] = v.Value 1326 } 1327 return tmp 1328 } 1329 1330 // This is useful with survey prompting library 1331 func (o *MapFloat32Option) WriteAnswer(name string, value interface{}) error { 1332 tmp := Float32Option{} 1333 if v, ok := value.(float32); ok { 1334 tmp.Value = v 1335 tmp.Defined = true 1336 tmp.Source = "prompt" 1337 (*o)[name] = tmp 1338 return nil 1339 } 1340 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 1341 } 1342 1343 func (o MapFloat32Option) IsDefined() bool { 1344 // true if the map has any keys 1345 if len(o) > 0 { 1346 return true 1347 } 1348 return false 1349 } 1350 1351 type ListFloat32Option []Float32Option 1352 1353 // Set is required for kingpin interfaces to allow command line params 1354 // to be set to our map datatype 1355 func (o *ListFloat32Option) Set(value string) error { 1356 val := Float32Option{} 1357 val.Set(value) 1358 *o = append(*o, val) 1359 return nil 1360 } 1361 1362 // This is useful with survey prompting library 1363 func (o *ListFloat32Option) WriteAnswer(name string, value interface{}) error { 1364 tmp := Float32Option{} 1365 if v, ok := value.(float32); ok { 1366 tmp.Value = v 1367 tmp.Defined = true 1368 tmp.Source = "prompt" 1369 *o = append(*o, tmp) 1370 return nil 1371 } 1372 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 1373 } 1374 1375 // IsCumulative is required for kingpin interfaces to allow multiple values 1376 // to be set on the data structure. 1377 func (o ListFloat32Option) IsCumulative() bool { 1378 return true 1379 } 1380 1381 // String is required for kingpin to generate usage with this datatype 1382 func (o ListFloat32Option) String() string { 1383 return fmt.Sprintf("%v", []Float32Option(o)) 1384 } 1385 1386 func (o ListFloat32Option) Append(values ...float32) ListFloat32Option { 1387 results := o 1388 for _, val := range values { 1389 results = append(results, NewFloat32Option(val)) 1390 } 1391 return results 1392 } 1393 1394 func (o ListFloat32Option) Slice() []float32 { 1395 tmp := []float32{} 1396 for _, elem := range o { 1397 tmp = append(tmp, elem.Value) 1398 } 1399 return tmp 1400 } 1401 1402 func (o ListFloat32Option) IsDefined() bool { 1403 // true if the list is not empty 1404 if len(o) > 0 { 1405 return true 1406 } 1407 return false 1408 } 1409 1410 type Float64Option struct { 1411 Source string 1412 Defined bool 1413 Value float64 1414 } 1415 1416 func NewFloat64Option(dflt float64) Float64Option { 1417 return Float64Option{ 1418 Source: "default", 1419 Defined: true, 1420 Value: dflt, 1421 } 1422 } 1423 1424 func (o Float64Option) IsDefined() bool { 1425 return o.Defined 1426 } 1427 1428 func (o *Float64Option) SetSource(source string) { 1429 o.Source = source 1430 } 1431 1432 func (o *Float64Option) GetSource() string { 1433 return o.Source 1434 } 1435 1436 func (o Float64Option) GetValue() interface{} { 1437 return o.Value 1438 } 1439 1440 // This is useful with kingpin option parser 1441 func (o *Float64Option) Set(s string) error { 1442 err := convertString(s, &o.Value) 1443 if err != nil { 1444 return err 1445 } 1446 o.Source = "override" 1447 o.Defined = true 1448 return nil 1449 } 1450 1451 // This is useful with survey prompting library 1452 func (o *Float64Option) WriteAnswer(name string, value interface{}) error { 1453 if v, ok := value.(float64); ok { 1454 o.Value = v 1455 o.Defined = true 1456 o.Source = "prompt" 1457 return nil 1458 } 1459 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 1460 } 1461 1462 func (o *Float64Option) SetValue(v interface{}) error { 1463 if val, ok := v.(float64); ok { 1464 o.Value = val 1465 o.Defined = true 1466 return nil 1467 } 1468 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 1469 } 1470 1471 func (o *Float64Option) UnmarshalYAML(unmarshal func(interface{}) error) error { 1472 if err := unmarshal(&o.Value); err != nil { 1473 return err 1474 } 1475 o.Source = "yaml" 1476 o.Defined = true 1477 return nil 1478 } 1479 1480 func (o *Float64Option) UnmarshalJSON(b []byte) error { 1481 if err := json.Unmarshal(b, &o.Value); err != nil { 1482 return err 1483 } 1484 o.Source = "json" 1485 o.Defined = true 1486 return nil 1487 } 1488 1489 func (o Float64Option) MarshalYAML() (interface{}, error) { 1490 if StringifyValue { 1491 return o.Value, nil 1492 } 1493 // need a copy of this struct without the MarshalYAML interface attached 1494 return struct { 1495 Value float64 1496 Source string 1497 Defined bool 1498 }{ 1499 Value: o.Value, 1500 Source: o.Source, 1501 Defined: o.Defined, 1502 }, nil 1503 } 1504 1505 func (o Float64Option) MarshalJSON() ([]byte, error) { 1506 if StringifyValue { 1507 return json.Marshal(o.Value) 1508 } 1509 // need a copy of this struct without the MarshalJSON interface attached 1510 return json.Marshal(struct { 1511 Value float64 1512 Source string 1513 Defined bool 1514 }{ 1515 Value: o.Value, 1516 Source: o.Source, 1517 Defined: o.Defined, 1518 }) 1519 } 1520 1521 // String is required for kingpin to generate usage with this datatype 1522 func (o Float64Option) String() string { 1523 if StringifyValue { 1524 return fmt.Sprintf("%v", o.Value) 1525 } 1526 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 1527 } 1528 1529 type MapFloat64Option map[string]Float64Option 1530 1531 // Set is required for kingpin interfaces to allow command line params 1532 // to be set to our map datatype 1533 func (o *MapFloat64Option) Set(value string) error { 1534 parts := stringMapRegex.Split(value, 2) 1535 if len(parts) != 2 { 1536 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 1537 } 1538 val := Float64Option{} 1539 val.Set(parts[1]) 1540 (*o)[parts[0]] = val 1541 return nil 1542 } 1543 1544 // IsCumulative is required for kingpin interfaces to allow multiple values 1545 // to be set on the data structure. 1546 func (o MapFloat64Option) IsCumulative() bool { 1547 return true 1548 } 1549 1550 // String is required for kingpin to generate usage with this datatype 1551 func (o MapFloat64Option) String() string { 1552 return fmt.Sprintf("%v", map[string]Float64Option(o)) 1553 } 1554 1555 func (o MapFloat64Option) Map() map[string]float64 { 1556 tmp := map[string]float64{} 1557 for k, v := range o { 1558 tmp[k] = v.Value 1559 } 1560 return tmp 1561 } 1562 1563 // This is useful with survey prompting library 1564 func (o *MapFloat64Option) WriteAnswer(name string, value interface{}) error { 1565 tmp := Float64Option{} 1566 if v, ok := value.(float64); ok { 1567 tmp.Value = v 1568 tmp.Defined = true 1569 tmp.Source = "prompt" 1570 (*o)[name] = tmp 1571 return nil 1572 } 1573 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 1574 } 1575 1576 func (o MapFloat64Option) IsDefined() bool { 1577 // true if the map has any keys 1578 if len(o) > 0 { 1579 return true 1580 } 1581 return false 1582 } 1583 1584 type ListFloat64Option []Float64Option 1585 1586 // Set is required for kingpin interfaces to allow command line params 1587 // to be set to our map datatype 1588 func (o *ListFloat64Option) Set(value string) error { 1589 val := Float64Option{} 1590 val.Set(value) 1591 *o = append(*o, val) 1592 return nil 1593 } 1594 1595 // This is useful with survey prompting library 1596 func (o *ListFloat64Option) WriteAnswer(name string, value interface{}) error { 1597 tmp := Float64Option{} 1598 if v, ok := value.(float64); ok { 1599 tmp.Value = v 1600 tmp.Defined = true 1601 tmp.Source = "prompt" 1602 *o = append(*o, tmp) 1603 return nil 1604 } 1605 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 1606 } 1607 1608 // IsCumulative is required for kingpin interfaces to allow multiple values 1609 // to be set on the data structure. 1610 func (o ListFloat64Option) IsCumulative() bool { 1611 return true 1612 } 1613 1614 // String is required for kingpin to generate usage with this datatype 1615 func (o ListFloat64Option) String() string { 1616 return fmt.Sprintf("%v", []Float64Option(o)) 1617 } 1618 1619 func (o ListFloat64Option) Append(values ...float64) ListFloat64Option { 1620 results := o 1621 for _, val := range values { 1622 results = append(results, NewFloat64Option(val)) 1623 } 1624 return results 1625 } 1626 1627 func (o ListFloat64Option) Slice() []float64 { 1628 tmp := []float64{} 1629 for _, elem := range o { 1630 tmp = append(tmp, elem.Value) 1631 } 1632 return tmp 1633 } 1634 1635 func (o ListFloat64Option) IsDefined() bool { 1636 // true if the list is not empty 1637 if len(o) > 0 { 1638 return true 1639 } 1640 return false 1641 } 1642 1643 type IntOption struct { 1644 Source string 1645 Defined bool 1646 Value int 1647 } 1648 1649 func NewIntOption(dflt int) IntOption { 1650 return IntOption{ 1651 Source: "default", 1652 Defined: true, 1653 Value: dflt, 1654 } 1655 } 1656 1657 func (o IntOption) IsDefined() bool { 1658 return o.Defined 1659 } 1660 1661 func (o *IntOption) SetSource(source string) { 1662 o.Source = source 1663 } 1664 1665 func (o *IntOption) GetSource() string { 1666 return o.Source 1667 } 1668 1669 func (o IntOption) GetValue() interface{} { 1670 return o.Value 1671 } 1672 1673 // This is useful with kingpin option parser 1674 func (o *IntOption) Set(s string) error { 1675 err := convertString(s, &o.Value) 1676 if err != nil { 1677 return err 1678 } 1679 o.Source = "override" 1680 o.Defined = true 1681 return nil 1682 } 1683 1684 // This is useful with survey prompting library 1685 func (o *IntOption) WriteAnswer(name string, value interface{}) error { 1686 if v, ok := value.(int); ok { 1687 o.Value = v 1688 o.Defined = true 1689 o.Source = "prompt" 1690 return nil 1691 } 1692 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 1693 } 1694 1695 func (o *IntOption) SetValue(v interface{}) error { 1696 if val, ok := v.(int); ok { 1697 o.Value = val 1698 o.Defined = true 1699 return nil 1700 } 1701 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 1702 } 1703 1704 func (o *IntOption) UnmarshalYAML(unmarshal func(interface{}) error) error { 1705 if err := unmarshal(&o.Value); err != nil { 1706 return err 1707 } 1708 o.Source = "yaml" 1709 o.Defined = true 1710 return nil 1711 } 1712 1713 func (o *IntOption) UnmarshalJSON(b []byte) error { 1714 if err := json.Unmarshal(b, &o.Value); err != nil { 1715 return err 1716 } 1717 o.Source = "json" 1718 o.Defined = true 1719 return nil 1720 } 1721 1722 func (o IntOption) MarshalYAML() (interface{}, error) { 1723 if StringifyValue { 1724 return o.Value, nil 1725 } 1726 // need a copy of this struct without the MarshalYAML interface attached 1727 return struct { 1728 Value int 1729 Source string 1730 Defined bool 1731 }{ 1732 Value: o.Value, 1733 Source: o.Source, 1734 Defined: o.Defined, 1735 }, nil 1736 } 1737 1738 func (o IntOption) MarshalJSON() ([]byte, error) { 1739 if StringifyValue { 1740 return json.Marshal(o.Value) 1741 } 1742 // need a copy of this struct without the MarshalJSON interface attached 1743 return json.Marshal(struct { 1744 Value int 1745 Source string 1746 Defined bool 1747 }{ 1748 Value: o.Value, 1749 Source: o.Source, 1750 Defined: o.Defined, 1751 }) 1752 } 1753 1754 // String is required for kingpin to generate usage with this datatype 1755 func (o IntOption) String() string { 1756 if StringifyValue { 1757 return fmt.Sprintf("%v", o.Value) 1758 } 1759 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 1760 } 1761 1762 type MapIntOption map[string]IntOption 1763 1764 // Set is required for kingpin interfaces to allow command line params 1765 // to be set to our map datatype 1766 func (o *MapIntOption) Set(value string) error { 1767 parts := stringMapRegex.Split(value, 2) 1768 if len(parts) != 2 { 1769 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 1770 } 1771 val := IntOption{} 1772 val.Set(parts[1]) 1773 (*o)[parts[0]] = val 1774 return nil 1775 } 1776 1777 // IsCumulative is required for kingpin interfaces to allow multiple values 1778 // to be set on the data structure. 1779 func (o MapIntOption) IsCumulative() bool { 1780 return true 1781 } 1782 1783 // String is required for kingpin to generate usage with this datatype 1784 func (o MapIntOption) String() string { 1785 return fmt.Sprintf("%v", map[string]IntOption(o)) 1786 } 1787 1788 func (o MapIntOption) Map() map[string]int { 1789 tmp := map[string]int{} 1790 for k, v := range o { 1791 tmp[k] = v.Value 1792 } 1793 return tmp 1794 } 1795 1796 // This is useful with survey prompting library 1797 func (o *MapIntOption) WriteAnswer(name string, value interface{}) error { 1798 tmp := IntOption{} 1799 if v, ok := value.(int); ok { 1800 tmp.Value = v 1801 tmp.Defined = true 1802 tmp.Source = "prompt" 1803 (*o)[name] = tmp 1804 return nil 1805 } 1806 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 1807 } 1808 1809 func (o MapIntOption) IsDefined() bool { 1810 // true if the map has any keys 1811 if len(o) > 0 { 1812 return true 1813 } 1814 return false 1815 } 1816 1817 type ListIntOption []IntOption 1818 1819 // Set is required for kingpin interfaces to allow command line params 1820 // to be set to our map datatype 1821 func (o *ListIntOption) Set(value string) error { 1822 val := IntOption{} 1823 val.Set(value) 1824 *o = append(*o, val) 1825 return nil 1826 } 1827 1828 // This is useful with survey prompting library 1829 func (o *ListIntOption) WriteAnswer(name string, value interface{}) error { 1830 tmp := IntOption{} 1831 if v, ok := value.(int); ok { 1832 tmp.Value = v 1833 tmp.Defined = true 1834 tmp.Source = "prompt" 1835 *o = append(*o, tmp) 1836 return nil 1837 } 1838 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 1839 } 1840 1841 // IsCumulative is required for kingpin interfaces to allow multiple values 1842 // to be set on the data structure. 1843 func (o ListIntOption) IsCumulative() bool { 1844 return true 1845 } 1846 1847 // String is required for kingpin to generate usage with this datatype 1848 func (o ListIntOption) String() string { 1849 return fmt.Sprintf("%v", []IntOption(o)) 1850 } 1851 1852 func (o ListIntOption) Append(values ...int) ListIntOption { 1853 results := o 1854 for _, val := range values { 1855 results = append(results, NewIntOption(val)) 1856 } 1857 return results 1858 } 1859 1860 func (o ListIntOption) Slice() []int { 1861 tmp := []int{} 1862 for _, elem := range o { 1863 tmp = append(tmp, elem.Value) 1864 } 1865 return tmp 1866 } 1867 1868 func (o ListIntOption) IsDefined() bool { 1869 // true if the list is not empty 1870 if len(o) > 0 { 1871 return true 1872 } 1873 return false 1874 } 1875 1876 type Int16Option struct { 1877 Source string 1878 Defined bool 1879 Value int16 1880 } 1881 1882 func NewInt16Option(dflt int16) Int16Option { 1883 return Int16Option{ 1884 Source: "default", 1885 Defined: true, 1886 Value: dflt, 1887 } 1888 } 1889 1890 func (o Int16Option) IsDefined() bool { 1891 return o.Defined 1892 } 1893 1894 func (o *Int16Option) SetSource(source string) { 1895 o.Source = source 1896 } 1897 1898 func (o *Int16Option) GetSource() string { 1899 return o.Source 1900 } 1901 1902 func (o Int16Option) GetValue() interface{} { 1903 return o.Value 1904 } 1905 1906 // This is useful with kingpin option parser 1907 func (o *Int16Option) Set(s string) error { 1908 err := convertString(s, &o.Value) 1909 if err != nil { 1910 return err 1911 } 1912 o.Source = "override" 1913 o.Defined = true 1914 return nil 1915 } 1916 1917 // This is useful with survey prompting library 1918 func (o *Int16Option) WriteAnswer(name string, value interface{}) error { 1919 if v, ok := value.(int16); ok { 1920 o.Value = v 1921 o.Defined = true 1922 o.Source = "prompt" 1923 return nil 1924 } 1925 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 1926 } 1927 1928 func (o *Int16Option) SetValue(v interface{}) error { 1929 if val, ok := v.(int16); ok { 1930 o.Value = val 1931 o.Defined = true 1932 return nil 1933 } 1934 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 1935 } 1936 1937 func (o *Int16Option) UnmarshalYAML(unmarshal func(interface{}) error) error { 1938 if err := unmarshal(&o.Value); err != nil { 1939 return err 1940 } 1941 o.Source = "yaml" 1942 o.Defined = true 1943 return nil 1944 } 1945 1946 func (o *Int16Option) UnmarshalJSON(b []byte) error { 1947 if err := json.Unmarshal(b, &o.Value); err != nil { 1948 return err 1949 } 1950 o.Source = "json" 1951 o.Defined = true 1952 return nil 1953 } 1954 1955 func (o Int16Option) MarshalYAML() (interface{}, error) { 1956 if StringifyValue { 1957 return o.Value, nil 1958 } 1959 // need a copy of this struct without the MarshalYAML interface attached 1960 return struct { 1961 Value int16 1962 Source string 1963 Defined bool 1964 }{ 1965 Value: o.Value, 1966 Source: o.Source, 1967 Defined: o.Defined, 1968 }, nil 1969 } 1970 1971 func (o Int16Option) MarshalJSON() ([]byte, error) { 1972 if StringifyValue { 1973 return json.Marshal(o.Value) 1974 } 1975 // need a copy of this struct without the MarshalJSON interface attached 1976 return json.Marshal(struct { 1977 Value int16 1978 Source string 1979 Defined bool 1980 }{ 1981 Value: o.Value, 1982 Source: o.Source, 1983 Defined: o.Defined, 1984 }) 1985 } 1986 1987 // String is required for kingpin to generate usage with this datatype 1988 func (o Int16Option) String() string { 1989 if StringifyValue { 1990 return fmt.Sprintf("%v", o.Value) 1991 } 1992 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 1993 } 1994 1995 type MapInt16Option map[string]Int16Option 1996 1997 // Set is required for kingpin interfaces to allow command line params 1998 // to be set to our map datatype 1999 func (o *MapInt16Option) Set(value string) error { 2000 parts := stringMapRegex.Split(value, 2) 2001 if len(parts) != 2 { 2002 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 2003 } 2004 val := Int16Option{} 2005 val.Set(parts[1]) 2006 (*o)[parts[0]] = val 2007 return nil 2008 } 2009 2010 // IsCumulative is required for kingpin interfaces to allow multiple values 2011 // to be set on the data structure. 2012 func (o MapInt16Option) IsCumulative() bool { 2013 return true 2014 } 2015 2016 // String is required for kingpin to generate usage with this datatype 2017 func (o MapInt16Option) String() string { 2018 return fmt.Sprintf("%v", map[string]Int16Option(o)) 2019 } 2020 2021 func (o MapInt16Option) Map() map[string]int16 { 2022 tmp := map[string]int16{} 2023 for k, v := range o { 2024 tmp[k] = v.Value 2025 } 2026 return tmp 2027 } 2028 2029 // This is useful with survey prompting library 2030 func (o *MapInt16Option) WriteAnswer(name string, value interface{}) error { 2031 tmp := Int16Option{} 2032 if v, ok := value.(int16); ok { 2033 tmp.Value = v 2034 tmp.Defined = true 2035 tmp.Source = "prompt" 2036 (*o)[name] = tmp 2037 return nil 2038 } 2039 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 2040 } 2041 2042 func (o MapInt16Option) IsDefined() bool { 2043 // true if the map has any keys 2044 if len(o) > 0 { 2045 return true 2046 } 2047 return false 2048 } 2049 2050 type ListInt16Option []Int16Option 2051 2052 // Set is required for kingpin interfaces to allow command line params 2053 // to be set to our map datatype 2054 func (o *ListInt16Option) Set(value string) error { 2055 val := Int16Option{} 2056 val.Set(value) 2057 *o = append(*o, val) 2058 return nil 2059 } 2060 2061 // This is useful with survey prompting library 2062 func (o *ListInt16Option) WriteAnswer(name string, value interface{}) error { 2063 tmp := Int16Option{} 2064 if v, ok := value.(int16); ok { 2065 tmp.Value = v 2066 tmp.Defined = true 2067 tmp.Source = "prompt" 2068 *o = append(*o, tmp) 2069 return nil 2070 } 2071 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 2072 } 2073 2074 // IsCumulative is required for kingpin interfaces to allow multiple values 2075 // to be set on the data structure. 2076 func (o ListInt16Option) IsCumulative() bool { 2077 return true 2078 } 2079 2080 // String is required for kingpin to generate usage with this datatype 2081 func (o ListInt16Option) String() string { 2082 return fmt.Sprintf("%v", []Int16Option(o)) 2083 } 2084 2085 func (o ListInt16Option) Append(values ...int16) ListInt16Option { 2086 results := o 2087 for _, val := range values { 2088 results = append(results, NewInt16Option(val)) 2089 } 2090 return results 2091 } 2092 2093 func (o ListInt16Option) Slice() []int16 { 2094 tmp := []int16{} 2095 for _, elem := range o { 2096 tmp = append(tmp, elem.Value) 2097 } 2098 return tmp 2099 } 2100 2101 func (o ListInt16Option) IsDefined() bool { 2102 // true if the list is not empty 2103 if len(o) > 0 { 2104 return true 2105 } 2106 return false 2107 } 2108 2109 type Int32Option struct { 2110 Source string 2111 Defined bool 2112 Value int32 2113 } 2114 2115 func NewInt32Option(dflt int32) Int32Option { 2116 return Int32Option{ 2117 Source: "default", 2118 Defined: true, 2119 Value: dflt, 2120 } 2121 } 2122 2123 func (o Int32Option) IsDefined() bool { 2124 return o.Defined 2125 } 2126 2127 func (o *Int32Option) SetSource(source string) { 2128 o.Source = source 2129 } 2130 2131 func (o *Int32Option) GetSource() string { 2132 return o.Source 2133 } 2134 2135 func (o Int32Option) GetValue() interface{} { 2136 return o.Value 2137 } 2138 2139 // This is useful with kingpin option parser 2140 func (o *Int32Option) Set(s string) error { 2141 err := convertString(s, &o.Value) 2142 if err != nil { 2143 return err 2144 } 2145 o.Source = "override" 2146 o.Defined = true 2147 return nil 2148 } 2149 2150 // This is useful with survey prompting library 2151 func (o *Int32Option) WriteAnswer(name string, value interface{}) error { 2152 if v, ok := value.(int32); ok { 2153 o.Value = v 2154 o.Defined = true 2155 o.Source = "prompt" 2156 return nil 2157 } 2158 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 2159 } 2160 2161 func (o *Int32Option) SetValue(v interface{}) error { 2162 if val, ok := v.(int32); ok { 2163 o.Value = val 2164 o.Defined = true 2165 return nil 2166 } 2167 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 2168 } 2169 2170 func (o *Int32Option) UnmarshalYAML(unmarshal func(interface{}) error) error { 2171 if err := unmarshal(&o.Value); err != nil { 2172 return err 2173 } 2174 o.Source = "yaml" 2175 o.Defined = true 2176 return nil 2177 } 2178 2179 func (o *Int32Option) UnmarshalJSON(b []byte) error { 2180 if err := json.Unmarshal(b, &o.Value); err != nil { 2181 return err 2182 } 2183 o.Source = "json" 2184 o.Defined = true 2185 return nil 2186 } 2187 2188 func (o Int32Option) MarshalYAML() (interface{}, error) { 2189 if StringifyValue { 2190 return o.Value, nil 2191 } 2192 // need a copy of this struct without the MarshalYAML interface attached 2193 return struct { 2194 Value int32 2195 Source string 2196 Defined bool 2197 }{ 2198 Value: o.Value, 2199 Source: o.Source, 2200 Defined: o.Defined, 2201 }, nil 2202 } 2203 2204 func (o Int32Option) MarshalJSON() ([]byte, error) { 2205 if StringifyValue { 2206 return json.Marshal(o.Value) 2207 } 2208 // need a copy of this struct without the MarshalJSON interface attached 2209 return json.Marshal(struct { 2210 Value int32 2211 Source string 2212 Defined bool 2213 }{ 2214 Value: o.Value, 2215 Source: o.Source, 2216 Defined: o.Defined, 2217 }) 2218 } 2219 2220 // String is required for kingpin to generate usage with this datatype 2221 func (o Int32Option) String() string { 2222 if StringifyValue { 2223 return fmt.Sprintf("%v", o.Value) 2224 } 2225 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 2226 } 2227 2228 type MapInt32Option map[string]Int32Option 2229 2230 // Set is required for kingpin interfaces to allow command line params 2231 // to be set to our map datatype 2232 func (o *MapInt32Option) Set(value string) error { 2233 parts := stringMapRegex.Split(value, 2) 2234 if len(parts) != 2 { 2235 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 2236 } 2237 val := Int32Option{} 2238 val.Set(parts[1]) 2239 (*o)[parts[0]] = val 2240 return nil 2241 } 2242 2243 // IsCumulative is required for kingpin interfaces to allow multiple values 2244 // to be set on the data structure. 2245 func (o MapInt32Option) IsCumulative() bool { 2246 return true 2247 } 2248 2249 // String is required for kingpin to generate usage with this datatype 2250 func (o MapInt32Option) String() string { 2251 return fmt.Sprintf("%v", map[string]Int32Option(o)) 2252 } 2253 2254 func (o MapInt32Option) Map() map[string]int32 { 2255 tmp := map[string]int32{} 2256 for k, v := range o { 2257 tmp[k] = v.Value 2258 } 2259 return tmp 2260 } 2261 2262 // This is useful with survey prompting library 2263 func (o *MapInt32Option) WriteAnswer(name string, value interface{}) error { 2264 tmp := Int32Option{} 2265 if v, ok := value.(int32); ok { 2266 tmp.Value = v 2267 tmp.Defined = true 2268 tmp.Source = "prompt" 2269 (*o)[name] = tmp 2270 return nil 2271 } 2272 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 2273 } 2274 2275 func (o MapInt32Option) IsDefined() bool { 2276 // true if the map has any keys 2277 if len(o) > 0 { 2278 return true 2279 } 2280 return false 2281 } 2282 2283 type ListInt32Option []Int32Option 2284 2285 // Set is required for kingpin interfaces to allow command line params 2286 // to be set to our map datatype 2287 func (o *ListInt32Option) Set(value string) error { 2288 val := Int32Option{} 2289 val.Set(value) 2290 *o = append(*o, val) 2291 return nil 2292 } 2293 2294 // This is useful with survey prompting library 2295 func (o *ListInt32Option) WriteAnswer(name string, value interface{}) error { 2296 tmp := Int32Option{} 2297 if v, ok := value.(int32); ok { 2298 tmp.Value = v 2299 tmp.Defined = true 2300 tmp.Source = "prompt" 2301 *o = append(*o, tmp) 2302 return nil 2303 } 2304 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 2305 } 2306 2307 // IsCumulative is required for kingpin interfaces to allow multiple values 2308 // to be set on the data structure. 2309 func (o ListInt32Option) IsCumulative() bool { 2310 return true 2311 } 2312 2313 // String is required for kingpin to generate usage with this datatype 2314 func (o ListInt32Option) String() string { 2315 return fmt.Sprintf("%v", []Int32Option(o)) 2316 } 2317 2318 func (o ListInt32Option) Append(values ...int32) ListInt32Option { 2319 results := o 2320 for _, val := range values { 2321 results = append(results, NewInt32Option(val)) 2322 } 2323 return results 2324 } 2325 2326 func (o ListInt32Option) Slice() []int32 { 2327 tmp := []int32{} 2328 for _, elem := range o { 2329 tmp = append(tmp, elem.Value) 2330 } 2331 return tmp 2332 } 2333 2334 func (o ListInt32Option) IsDefined() bool { 2335 // true if the list is not empty 2336 if len(o) > 0 { 2337 return true 2338 } 2339 return false 2340 } 2341 2342 type Int64Option struct { 2343 Source string 2344 Defined bool 2345 Value int64 2346 } 2347 2348 func NewInt64Option(dflt int64) Int64Option { 2349 return Int64Option{ 2350 Source: "default", 2351 Defined: true, 2352 Value: dflt, 2353 } 2354 } 2355 2356 func (o Int64Option) IsDefined() bool { 2357 return o.Defined 2358 } 2359 2360 func (o *Int64Option) SetSource(source string) { 2361 o.Source = source 2362 } 2363 2364 func (o *Int64Option) GetSource() string { 2365 return o.Source 2366 } 2367 2368 func (o Int64Option) GetValue() interface{} { 2369 return o.Value 2370 } 2371 2372 // This is useful with kingpin option parser 2373 func (o *Int64Option) Set(s string) error { 2374 err := convertString(s, &o.Value) 2375 if err != nil { 2376 return err 2377 } 2378 o.Source = "override" 2379 o.Defined = true 2380 return nil 2381 } 2382 2383 // This is useful with survey prompting library 2384 func (o *Int64Option) WriteAnswer(name string, value interface{}) error { 2385 if v, ok := value.(int64); ok { 2386 o.Value = v 2387 o.Defined = true 2388 o.Source = "prompt" 2389 return nil 2390 } 2391 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 2392 } 2393 2394 func (o *Int64Option) SetValue(v interface{}) error { 2395 if val, ok := v.(int64); ok { 2396 o.Value = val 2397 o.Defined = true 2398 return nil 2399 } 2400 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 2401 } 2402 2403 func (o *Int64Option) UnmarshalYAML(unmarshal func(interface{}) error) error { 2404 if err := unmarshal(&o.Value); err != nil { 2405 return err 2406 } 2407 o.Source = "yaml" 2408 o.Defined = true 2409 return nil 2410 } 2411 2412 func (o *Int64Option) UnmarshalJSON(b []byte) error { 2413 if err := json.Unmarshal(b, &o.Value); err != nil { 2414 return err 2415 } 2416 o.Source = "json" 2417 o.Defined = true 2418 return nil 2419 } 2420 2421 func (o Int64Option) MarshalYAML() (interface{}, error) { 2422 if StringifyValue { 2423 return o.Value, nil 2424 } 2425 // need a copy of this struct without the MarshalYAML interface attached 2426 return struct { 2427 Value int64 2428 Source string 2429 Defined bool 2430 }{ 2431 Value: o.Value, 2432 Source: o.Source, 2433 Defined: o.Defined, 2434 }, nil 2435 } 2436 2437 func (o Int64Option) MarshalJSON() ([]byte, error) { 2438 if StringifyValue { 2439 return json.Marshal(o.Value) 2440 } 2441 // need a copy of this struct without the MarshalJSON interface attached 2442 return json.Marshal(struct { 2443 Value int64 2444 Source string 2445 Defined bool 2446 }{ 2447 Value: o.Value, 2448 Source: o.Source, 2449 Defined: o.Defined, 2450 }) 2451 } 2452 2453 // String is required for kingpin to generate usage with this datatype 2454 func (o Int64Option) String() string { 2455 if StringifyValue { 2456 return fmt.Sprintf("%v", o.Value) 2457 } 2458 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 2459 } 2460 2461 type MapInt64Option map[string]Int64Option 2462 2463 // Set is required for kingpin interfaces to allow command line params 2464 // to be set to our map datatype 2465 func (o *MapInt64Option) Set(value string) error { 2466 parts := stringMapRegex.Split(value, 2) 2467 if len(parts) != 2 { 2468 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 2469 } 2470 val := Int64Option{} 2471 val.Set(parts[1]) 2472 (*o)[parts[0]] = val 2473 return nil 2474 } 2475 2476 // IsCumulative is required for kingpin interfaces to allow multiple values 2477 // to be set on the data structure. 2478 func (o MapInt64Option) IsCumulative() bool { 2479 return true 2480 } 2481 2482 // String is required for kingpin to generate usage with this datatype 2483 func (o MapInt64Option) String() string { 2484 return fmt.Sprintf("%v", map[string]Int64Option(o)) 2485 } 2486 2487 func (o MapInt64Option) Map() map[string]int64 { 2488 tmp := map[string]int64{} 2489 for k, v := range o { 2490 tmp[k] = v.Value 2491 } 2492 return tmp 2493 } 2494 2495 // This is useful with survey prompting library 2496 func (o *MapInt64Option) WriteAnswer(name string, value interface{}) error { 2497 tmp := Int64Option{} 2498 if v, ok := value.(int64); ok { 2499 tmp.Value = v 2500 tmp.Defined = true 2501 tmp.Source = "prompt" 2502 (*o)[name] = tmp 2503 return nil 2504 } 2505 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 2506 } 2507 2508 func (o MapInt64Option) IsDefined() bool { 2509 // true if the map has any keys 2510 if len(o) > 0 { 2511 return true 2512 } 2513 return false 2514 } 2515 2516 type ListInt64Option []Int64Option 2517 2518 // Set is required for kingpin interfaces to allow command line params 2519 // to be set to our map datatype 2520 func (o *ListInt64Option) Set(value string) error { 2521 val := Int64Option{} 2522 val.Set(value) 2523 *o = append(*o, val) 2524 return nil 2525 } 2526 2527 // This is useful with survey prompting library 2528 func (o *ListInt64Option) WriteAnswer(name string, value interface{}) error { 2529 tmp := Int64Option{} 2530 if v, ok := value.(int64); ok { 2531 tmp.Value = v 2532 tmp.Defined = true 2533 tmp.Source = "prompt" 2534 *o = append(*o, tmp) 2535 return nil 2536 } 2537 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 2538 } 2539 2540 // IsCumulative is required for kingpin interfaces to allow multiple values 2541 // to be set on the data structure. 2542 func (o ListInt64Option) IsCumulative() bool { 2543 return true 2544 } 2545 2546 // String is required for kingpin to generate usage with this datatype 2547 func (o ListInt64Option) String() string { 2548 return fmt.Sprintf("%v", []Int64Option(o)) 2549 } 2550 2551 func (o ListInt64Option) Append(values ...int64) ListInt64Option { 2552 results := o 2553 for _, val := range values { 2554 results = append(results, NewInt64Option(val)) 2555 } 2556 return results 2557 } 2558 2559 func (o ListInt64Option) Slice() []int64 { 2560 tmp := []int64{} 2561 for _, elem := range o { 2562 tmp = append(tmp, elem.Value) 2563 } 2564 return tmp 2565 } 2566 2567 func (o ListInt64Option) IsDefined() bool { 2568 // true if the list is not empty 2569 if len(o) > 0 { 2570 return true 2571 } 2572 return false 2573 } 2574 2575 type Int8Option struct { 2576 Source string 2577 Defined bool 2578 Value int8 2579 } 2580 2581 func NewInt8Option(dflt int8) Int8Option { 2582 return Int8Option{ 2583 Source: "default", 2584 Defined: true, 2585 Value: dflt, 2586 } 2587 } 2588 2589 func (o Int8Option) IsDefined() bool { 2590 return o.Defined 2591 } 2592 2593 func (o *Int8Option) SetSource(source string) { 2594 o.Source = source 2595 } 2596 2597 func (o *Int8Option) GetSource() string { 2598 return o.Source 2599 } 2600 2601 func (o Int8Option) GetValue() interface{} { 2602 return o.Value 2603 } 2604 2605 // This is useful with kingpin option parser 2606 func (o *Int8Option) Set(s string) error { 2607 err := convertString(s, &o.Value) 2608 if err != nil { 2609 return err 2610 } 2611 o.Source = "override" 2612 o.Defined = true 2613 return nil 2614 } 2615 2616 // This is useful with survey prompting library 2617 func (o *Int8Option) WriteAnswer(name string, value interface{}) error { 2618 if v, ok := value.(int8); ok { 2619 o.Value = v 2620 o.Defined = true 2621 o.Source = "prompt" 2622 return nil 2623 } 2624 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 2625 } 2626 2627 func (o *Int8Option) SetValue(v interface{}) error { 2628 if val, ok := v.(int8); ok { 2629 o.Value = val 2630 o.Defined = true 2631 return nil 2632 } 2633 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 2634 } 2635 2636 func (o *Int8Option) UnmarshalYAML(unmarshal func(interface{}) error) error { 2637 if err := unmarshal(&o.Value); err != nil { 2638 return err 2639 } 2640 o.Source = "yaml" 2641 o.Defined = true 2642 return nil 2643 } 2644 2645 func (o *Int8Option) UnmarshalJSON(b []byte) error { 2646 if err := json.Unmarshal(b, &o.Value); err != nil { 2647 return err 2648 } 2649 o.Source = "json" 2650 o.Defined = true 2651 return nil 2652 } 2653 2654 func (o Int8Option) MarshalYAML() (interface{}, error) { 2655 if StringifyValue { 2656 return o.Value, nil 2657 } 2658 // need a copy of this struct without the MarshalYAML interface attached 2659 return struct { 2660 Value int8 2661 Source string 2662 Defined bool 2663 }{ 2664 Value: o.Value, 2665 Source: o.Source, 2666 Defined: o.Defined, 2667 }, nil 2668 } 2669 2670 func (o Int8Option) MarshalJSON() ([]byte, error) { 2671 if StringifyValue { 2672 return json.Marshal(o.Value) 2673 } 2674 // need a copy of this struct without the MarshalJSON interface attached 2675 return json.Marshal(struct { 2676 Value int8 2677 Source string 2678 Defined bool 2679 }{ 2680 Value: o.Value, 2681 Source: o.Source, 2682 Defined: o.Defined, 2683 }) 2684 } 2685 2686 // String is required for kingpin to generate usage with this datatype 2687 func (o Int8Option) String() string { 2688 if StringifyValue { 2689 return fmt.Sprintf("%v", o.Value) 2690 } 2691 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 2692 } 2693 2694 type MapInt8Option map[string]Int8Option 2695 2696 // Set is required for kingpin interfaces to allow command line params 2697 // to be set to our map datatype 2698 func (o *MapInt8Option) Set(value string) error { 2699 parts := stringMapRegex.Split(value, 2) 2700 if len(parts) != 2 { 2701 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 2702 } 2703 val := Int8Option{} 2704 val.Set(parts[1]) 2705 (*o)[parts[0]] = val 2706 return nil 2707 } 2708 2709 // IsCumulative is required for kingpin interfaces to allow multiple values 2710 // to be set on the data structure. 2711 func (o MapInt8Option) IsCumulative() bool { 2712 return true 2713 } 2714 2715 // String is required for kingpin to generate usage with this datatype 2716 func (o MapInt8Option) String() string { 2717 return fmt.Sprintf("%v", map[string]Int8Option(o)) 2718 } 2719 2720 func (o MapInt8Option) Map() map[string]int8 { 2721 tmp := map[string]int8{} 2722 for k, v := range o { 2723 tmp[k] = v.Value 2724 } 2725 return tmp 2726 } 2727 2728 // This is useful with survey prompting library 2729 func (o *MapInt8Option) WriteAnswer(name string, value interface{}) error { 2730 tmp := Int8Option{} 2731 if v, ok := value.(int8); ok { 2732 tmp.Value = v 2733 tmp.Defined = true 2734 tmp.Source = "prompt" 2735 (*o)[name] = tmp 2736 return nil 2737 } 2738 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 2739 } 2740 2741 func (o MapInt8Option) IsDefined() bool { 2742 // true if the map has any keys 2743 if len(o) > 0 { 2744 return true 2745 } 2746 return false 2747 } 2748 2749 type ListInt8Option []Int8Option 2750 2751 // Set is required for kingpin interfaces to allow command line params 2752 // to be set to our map datatype 2753 func (o *ListInt8Option) Set(value string) error { 2754 val := Int8Option{} 2755 val.Set(value) 2756 *o = append(*o, val) 2757 return nil 2758 } 2759 2760 // This is useful with survey prompting library 2761 func (o *ListInt8Option) WriteAnswer(name string, value interface{}) error { 2762 tmp := Int8Option{} 2763 if v, ok := value.(int8); ok { 2764 tmp.Value = v 2765 tmp.Defined = true 2766 tmp.Source = "prompt" 2767 *o = append(*o, tmp) 2768 return nil 2769 } 2770 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 2771 } 2772 2773 // IsCumulative is required for kingpin interfaces to allow multiple values 2774 // to be set on the data structure. 2775 func (o ListInt8Option) IsCumulative() bool { 2776 return true 2777 } 2778 2779 // String is required for kingpin to generate usage with this datatype 2780 func (o ListInt8Option) String() string { 2781 return fmt.Sprintf("%v", []Int8Option(o)) 2782 } 2783 2784 func (o ListInt8Option) Append(values ...int8) ListInt8Option { 2785 results := o 2786 for _, val := range values { 2787 results = append(results, NewInt8Option(val)) 2788 } 2789 return results 2790 } 2791 2792 func (o ListInt8Option) Slice() []int8 { 2793 tmp := []int8{} 2794 for _, elem := range o { 2795 tmp = append(tmp, elem.Value) 2796 } 2797 return tmp 2798 } 2799 2800 func (o ListInt8Option) IsDefined() bool { 2801 // true if the list is not empty 2802 if len(o) > 0 { 2803 return true 2804 } 2805 return false 2806 } 2807 2808 type RuneOption struct { 2809 Source string 2810 Defined bool 2811 Value rune 2812 } 2813 2814 func NewRuneOption(dflt rune) RuneOption { 2815 return RuneOption{ 2816 Source: "default", 2817 Defined: true, 2818 Value: dflt, 2819 } 2820 } 2821 2822 func (o RuneOption) IsDefined() bool { 2823 return o.Defined 2824 } 2825 2826 func (o *RuneOption) SetSource(source string) { 2827 o.Source = source 2828 } 2829 2830 func (o *RuneOption) GetSource() string { 2831 return o.Source 2832 } 2833 2834 func (o RuneOption) GetValue() interface{} { 2835 return o.Value 2836 } 2837 2838 // This is useful with kingpin option parser 2839 func (o *RuneOption) Set(s string) error { 2840 err := convertString(s, &o.Value) 2841 if err != nil { 2842 return err 2843 } 2844 o.Source = "override" 2845 o.Defined = true 2846 return nil 2847 } 2848 2849 // This is useful with survey prompting library 2850 func (o *RuneOption) WriteAnswer(name string, value interface{}) error { 2851 if v, ok := value.(rune); ok { 2852 o.Value = v 2853 o.Defined = true 2854 o.Source = "prompt" 2855 return nil 2856 } 2857 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 2858 } 2859 2860 func (o *RuneOption) SetValue(v interface{}) error { 2861 if val, ok := v.(rune); ok { 2862 o.Value = val 2863 o.Defined = true 2864 return nil 2865 } 2866 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 2867 } 2868 2869 func (o *RuneOption) UnmarshalYAML(unmarshal func(interface{}) error) error { 2870 if err := unmarshal(&o.Value); err != nil { 2871 return err 2872 } 2873 o.Source = "yaml" 2874 o.Defined = true 2875 return nil 2876 } 2877 2878 func (o *RuneOption) UnmarshalJSON(b []byte) error { 2879 if err := json.Unmarshal(b, &o.Value); err != nil { 2880 return err 2881 } 2882 o.Source = "json" 2883 o.Defined = true 2884 return nil 2885 } 2886 2887 func (o RuneOption) MarshalYAML() (interface{}, error) { 2888 if StringifyValue { 2889 return o.Value, nil 2890 } 2891 // need a copy of this struct without the MarshalYAML interface attached 2892 return struct { 2893 Value rune 2894 Source string 2895 Defined bool 2896 }{ 2897 Value: o.Value, 2898 Source: o.Source, 2899 Defined: o.Defined, 2900 }, nil 2901 } 2902 2903 func (o RuneOption) MarshalJSON() ([]byte, error) { 2904 if StringifyValue { 2905 return json.Marshal(o.Value) 2906 } 2907 // need a copy of this struct without the MarshalJSON interface attached 2908 return json.Marshal(struct { 2909 Value rune 2910 Source string 2911 Defined bool 2912 }{ 2913 Value: o.Value, 2914 Source: o.Source, 2915 Defined: o.Defined, 2916 }) 2917 } 2918 2919 // String is required for kingpin to generate usage with this datatype 2920 func (o RuneOption) String() string { 2921 if StringifyValue { 2922 return fmt.Sprintf("%v", o.Value) 2923 } 2924 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 2925 } 2926 2927 type MapRuneOption map[string]RuneOption 2928 2929 // Set is required for kingpin interfaces to allow command line params 2930 // to be set to our map datatype 2931 func (o *MapRuneOption) Set(value string) error { 2932 parts := stringMapRegex.Split(value, 2) 2933 if len(parts) != 2 { 2934 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 2935 } 2936 val := RuneOption{} 2937 val.Set(parts[1]) 2938 (*o)[parts[0]] = val 2939 return nil 2940 } 2941 2942 // IsCumulative is required for kingpin interfaces to allow multiple values 2943 // to be set on the data structure. 2944 func (o MapRuneOption) IsCumulative() bool { 2945 return true 2946 } 2947 2948 // String is required for kingpin to generate usage with this datatype 2949 func (o MapRuneOption) String() string { 2950 return fmt.Sprintf("%v", map[string]RuneOption(o)) 2951 } 2952 2953 func (o MapRuneOption) Map() map[string]rune { 2954 tmp := map[string]rune{} 2955 for k, v := range o { 2956 tmp[k] = v.Value 2957 } 2958 return tmp 2959 } 2960 2961 // This is useful with survey prompting library 2962 func (o *MapRuneOption) WriteAnswer(name string, value interface{}) error { 2963 tmp := RuneOption{} 2964 if v, ok := value.(rune); ok { 2965 tmp.Value = v 2966 tmp.Defined = true 2967 tmp.Source = "prompt" 2968 (*o)[name] = tmp 2969 return nil 2970 } 2971 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 2972 } 2973 2974 func (o MapRuneOption) IsDefined() bool { 2975 // true if the map has any keys 2976 if len(o) > 0 { 2977 return true 2978 } 2979 return false 2980 } 2981 2982 type ListRuneOption []RuneOption 2983 2984 // Set is required for kingpin interfaces to allow command line params 2985 // to be set to our map datatype 2986 func (o *ListRuneOption) Set(value string) error { 2987 val := RuneOption{} 2988 val.Set(value) 2989 *o = append(*o, val) 2990 return nil 2991 } 2992 2993 // This is useful with survey prompting library 2994 func (o *ListRuneOption) WriteAnswer(name string, value interface{}) error { 2995 tmp := RuneOption{} 2996 if v, ok := value.(rune); ok { 2997 tmp.Value = v 2998 tmp.Defined = true 2999 tmp.Source = "prompt" 3000 *o = append(*o, tmp) 3001 return nil 3002 } 3003 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 3004 } 3005 3006 // IsCumulative is required for kingpin interfaces to allow multiple values 3007 // to be set on the data structure. 3008 func (o ListRuneOption) IsCumulative() bool { 3009 return true 3010 } 3011 3012 // String is required for kingpin to generate usage with this datatype 3013 func (o ListRuneOption) String() string { 3014 return fmt.Sprintf("%v", []RuneOption(o)) 3015 } 3016 3017 func (o ListRuneOption) Append(values ...rune) ListRuneOption { 3018 results := o 3019 for _, val := range values { 3020 results = append(results, NewRuneOption(val)) 3021 } 3022 return results 3023 } 3024 3025 func (o ListRuneOption) Slice() []rune { 3026 tmp := []rune{} 3027 for _, elem := range o { 3028 tmp = append(tmp, elem.Value) 3029 } 3030 return tmp 3031 } 3032 3033 func (o ListRuneOption) IsDefined() bool { 3034 // true if the list is not empty 3035 if len(o) > 0 { 3036 return true 3037 } 3038 return false 3039 } 3040 3041 type StringOption struct { 3042 Source string 3043 Defined bool 3044 Value string 3045 } 3046 3047 func NewStringOption(dflt string) StringOption { 3048 return StringOption{ 3049 Source: "default", 3050 Defined: true, 3051 Value: dflt, 3052 } 3053 } 3054 3055 func (o StringOption) IsDefined() bool { 3056 return o.Defined 3057 } 3058 3059 func (o *StringOption) SetSource(source string) { 3060 o.Source = source 3061 } 3062 3063 func (o *StringOption) GetSource() string { 3064 return o.Source 3065 } 3066 3067 func (o StringOption) GetValue() interface{} { 3068 return o.Value 3069 } 3070 3071 // This is useful with kingpin option parser 3072 func (o *StringOption) Set(s string) error { 3073 err := convertString(s, &o.Value) 3074 if err != nil { 3075 return err 3076 } 3077 o.Source = "override" 3078 o.Defined = true 3079 return nil 3080 } 3081 3082 // This is useful with survey prompting library 3083 func (o *StringOption) WriteAnswer(name string, value interface{}) error { 3084 if v, ok := value.(string); ok { 3085 o.Value = v 3086 o.Defined = true 3087 o.Source = "prompt" 3088 return nil 3089 } 3090 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 3091 } 3092 3093 func (o *StringOption) SetValue(v interface{}) error { 3094 if val, ok := v.(string); ok { 3095 o.Value = val 3096 o.Defined = true 3097 return nil 3098 } 3099 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 3100 } 3101 3102 func (o *StringOption) UnmarshalYAML(unmarshal func(interface{}) error) error { 3103 if err := unmarshal(&o.Value); err != nil { 3104 return err 3105 } 3106 o.Source = "yaml" 3107 o.Defined = true 3108 return nil 3109 } 3110 3111 func (o *StringOption) UnmarshalJSON(b []byte) error { 3112 if err := json.Unmarshal(b, &o.Value); err != nil { 3113 return err 3114 } 3115 o.Source = "json" 3116 o.Defined = true 3117 return nil 3118 } 3119 3120 func (o StringOption) MarshalYAML() (interface{}, error) { 3121 if StringifyValue { 3122 return o.Value, nil 3123 } 3124 // need a copy of this struct without the MarshalYAML interface attached 3125 return struct { 3126 Value string 3127 Source string 3128 Defined bool 3129 }{ 3130 Value: o.Value, 3131 Source: o.Source, 3132 Defined: o.Defined, 3133 }, nil 3134 } 3135 3136 func (o StringOption) MarshalJSON() ([]byte, error) { 3137 if StringifyValue { 3138 return json.Marshal(o.Value) 3139 } 3140 // need a copy of this struct without the MarshalJSON interface attached 3141 return json.Marshal(struct { 3142 Value string 3143 Source string 3144 Defined bool 3145 }{ 3146 Value: o.Value, 3147 Source: o.Source, 3148 Defined: o.Defined, 3149 }) 3150 } 3151 3152 // String is required for kingpin to generate usage with this datatype 3153 func (o StringOption) String() string { 3154 if StringifyValue { 3155 return fmt.Sprintf("%v", o.Value) 3156 } 3157 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 3158 } 3159 3160 type MapStringOption map[string]StringOption 3161 3162 // Set is required for kingpin interfaces to allow command line params 3163 // to be set to our map datatype 3164 func (o *MapStringOption) Set(value string) error { 3165 parts := stringMapRegex.Split(value, 2) 3166 if len(parts) != 2 { 3167 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 3168 } 3169 val := StringOption{} 3170 val.Set(parts[1]) 3171 (*o)[parts[0]] = val 3172 return nil 3173 } 3174 3175 // IsCumulative is required for kingpin interfaces to allow multiple values 3176 // to be set on the data structure. 3177 func (o MapStringOption) IsCumulative() bool { 3178 return true 3179 } 3180 3181 // String is required for kingpin to generate usage with this datatype 3182 func (o MapStringOption) String() string { 3183 return fmt.Sprintf("%v", map[string]StringOption(o)) 3184 } 3185 3186 func (o MapStringOption) Map() map[string]string { 3187 tmp := map[string]string{} 3188 for k, v := range o { 3189 tmp[k] = v.Value 3190 } 3191 return tmp 3192 } 3193 3194 // This is useful with survey prompting library 3195 func (o *MapStringOption) WriteAnswer(name string, value interface{}) error { 3196 tmp := StringOption{} 3197 if v, ok := value.(string); ok { 3198 tmp.Value = v 3199 tmp.Defined = true 3200 tmp.Source = "prompt" 3201 (*o)[name] = tmp 3202 return nil 3203 } 3204 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 3205 } 3206 3207 func (o MapStringOption) IsDefined() bool { 3208 // true if the map has any keys 3209 if len(o) > 0 { 3210 return true 3211 } 3212 return false 3213 } 3214 3215 type ListStringOption []StringOption 3216 3217 // Set is required for kingpin interfaces to allow command line params 3218 // to be set to our map datatype 3219 func (o *ListStringOption) Set(value string) error { 3220 val := StringOption{} 3221 val.Set(value) 3222 *o = append(*o, val) 3223 return nil 3224 } 3225 3226 // This is useful with survey prompting library 3227 func (o *ListStringOption) WriteAnswer(name string, value interface{}) error { 3228 tmp := StringOption{} 3229 if v, ok := value.(string); ok { 3230 tmp.Value = v 3231 tmp.Defined = true 3232 tmp.Source = "prompt" 3233 *o = append(*o, tmp) 3234 return nil 3235 } 3236 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 3237 } 3238 3239 // IsCumulative is required for kingpin interfaces to allow multiple values 3240 // to be set on the data structure. 3241 func (o ListStringOption) IsCumulative() bool { 3242 return true 3243 } 3244 3245 // String is required for kingpin to generate usage with this datatype 3246 func (o ListStringOption) String() string { 3247 return fmt.Sprintf("%v", []StringOption(o)) 3248 } 3249 3250 func (o ListStringOption) Append(values ...string) ListStringOption { 3251 results := o 3252 for _, val := range values { 3253 results = append(results, NewStringOption(val)) 3254 } 3255 return results 3256 } 3257 3258 func (o ListStringOption) Slice() []string { 3259 tmp := []string{} 3260 for _, elem := range o { 3261 tmp = append(tmp, elem.Value) 3262 } 3263 return tmp 3264 } 3265 3266 func (o ListStringOption) IsDefined() bool { 3267 // true if the list is not empty 3268 if len(o) > 0 { 3269 return true 3270 } 3271 return false 3272 } 3273 3274 type UintOption struct { 3275 Source string 3276 Defined bool 3277 Value uint 3278 } 3279 3280 func NewUintOption(dflt uint) UintOption { 3281 return UintOption{ 3282 Source: "default", 3283 Defined: true, 3284 Value: dflt, 3285 } 3286 } 3287 3288 func (o UintOption) IsDefined() bool { 3289 return o.Defined 3290 } 3291 3292 func (o *UintOption) SetSource(source string) { 3293 o.Source = source 3294 } 3295 3296 func (o *UintOption) GetSource() string { 3297 return o.Source 3298 } 3299 3300 func (o UintOption) GetValue() interface{} { 3301 return o.Value 3302 } 3303 3304 // This is useful with kingpin option parser 3305 func (o *UintOption) Set(s string) error { 3306 err := convertString(s, &o.Value) 3307 if err != nil { 3308 return err 3309 } 3310 o.Source = "override" 3311 o.Defined = true 3312 return nil 3313 } 3314 3315 // This is useful with survey prompting library 3316 func (o *UintOption) WriteAnswer(name string, value interface{}) error { 3317 if v, ok := value.(uint); ok { 3318 o.Value = v 3319 o.Defined = true 3320 o.Source = "prompt" 3321 return nil 3322 } 3323 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 3324 } 3325 3326 func (o *UintOption) SetValue(v interface{}) error { 3327 if val, ok := v.(uint); ok { 3328 o.Value = val 3329 o.Defined = true 3330 return nil 3331 } 3332 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 3333 } 3334 3335 func (o *UintOption) UnmarshalYAML(unmarshal func(interface{}) error) error { 3336 if err := unmarshal(&o.Value); err != nil { 3337 return err 3338 } 3339 o.Source = "yaml" 3340 o.Defined = true 3341 return nil 3342 } 3343 3344 func (o *UintOption) UnmarshalJSON(b []byte) error { 3345 if err := json.Unmarshal(b, &o.Value); err != nil { 3346 return err 3347 } 3348 o.Source = "json" 3349 o.Defined = true 3350 return nil 3351 } 3352 3353 func (o UintOption) MarshalYAML() (interface{}, error) { 3354 if StringifyValue { 3355 return o.Value, nil 3356 } 3357 // need a copy of this struct without the MarshalYAML interface attached 3358 return struct { 3359 Value uint 3360 Source string 3361 Defined bool 3362 }{ 3363 Value: o.Value, 3364 Source: o.Source, 3365 Defined: o.Defined, 3366 }, nil 3367 } 3368 3369 func (o UintOption) MarshalJSON() ([]byte, error) { 3370 if StringifyValue { 3371 return json.Marshal(o.Value) 3372 } 3373 // need a copy of this struct without the MarshalJSON interface attached 3374 return json.Marshal(struct { 3375 Value uint 3376 Source string 3377 Defined bool 3378 }{ 3379 Value: o.Value, 3380 Source: o.Source, 3381 Defined: o.Defined, 3382 }) 3383 } 3384 3385 // String is required for kingpin to generate usage with this datatype 3386 func (o UintOption) String() string { 3387 if StringifyValue { 3388 return fmt.Sprintf("%v", o.Value) 3389 } 3390 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 3391 } 3392 3393 type MapUintOption map[string]UintOption 3394 3395 // Set is required for kingpin interfaces to allow command line params 3396 // to be set to our map datatype 3397 func (o *MapUintOption) Set(value string) error { 3398 parts := stringMapRegex.Split(value, 2) 3399 if len(parts) != 2 { 3400 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 3401 } 3402 val := UintOption{} 3403 val.Set(parts[1]) 3404 (*o)[parts[0]] = val 3405 return nil 3406 } 3407 3408 // IsCumulative is required for kingpin interfaces to allow multiple values 3409 // to be set on the data structure. 3410 func (o MapUintOption) IsCumulative() bool { 3411 return true 3412 } 3413 3414 // String is required for kingpin to generate usage with this datatype 3415 func (o MapUintOption) String() string { 3416 return fmt.Sprintf("%v", map[string]UintOption(o)) 3417 } 3418 3419 func (o MapUintOption) Map() map[string]uint { 3420 tmp := map[string]uint{} 3421 for k, v := range o { 3422 tmp[k] = v.Value 3423 } 3424 return tmp 3425 } 3426 3427 // This is useful with survey prompting library 3428 func (o *MapUintOption) WriteAnswer(name string, value interface{}) error { 3429 tmp := UintOption{} 3430 if v, ok := value.(uint); ok { 3431 tmp.Value = v 3432 tmp.Defined = true 3433 tmp.Source = "prompt" 3434 (*o)[name] = tmp 3435 return nil 3436 } 3437 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 3438 } 3439 3440 func (o MapUintOption) IsDefined() bool { 3441 // true if the map has any keys 3442 if len(o) > 0 { 3443 return true 3444 } 3445 return false 3446 } 3447 3448 type ListUintOption []UintOption 3449 3450 // Set is required for kingpin interfaces to allow command line params 3451 // to be set to our map datatype 3452 func (o *ListUintOption) Set(value string) error { 3453 val := UintOption{} 3454 val.Set(value) 3455 *o = append(*o, val) 3456 return nil 3457 } 3458 3459 // This is useful with survey prompting library 3460 func (o *ListUintOption) WriteAnswer(name string, value interface{}) error { 3461 tmp := UintOption{} 3462 if v, ok := value.(uint); ok { 3463 tmp.Value = v 3464 tmp.Defined = true 3465 tmp.Source = "prompt" 3466 *o = append(*o, tmp) 3467 return nil 3468 } 3469 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 3470 } 3471 3472 // IsCumulative is required for kingpin interfaces to allow multiple values 3473 // to be set on the data structure. 3474 func (o ListUintOption) IsCumulative() bool { 3475 return true 3476 } 3477 3478 // String is required for kingpin to generate usage with this datatype 3479 func (o ListUintOption) String() string { 3480 return fmt.Sprintf("%v", []UintOption(o)) 3481 } 3482 3483 func (o ListUintOption) Append(values ...uint) ListUintOption { 3484 results := o 3485 for _, val := range values { 3486 results = append(results, NewUintOption(val)) 3487 } 3488 return results 3489 } 3490 3491 func (o ListUintOption) Slice() []uint { 3492 tmp := []uint{} 3493 for _, elem := range o { 3494 tmp = append(tmp, elem.Value) 3495 } 3496 return tmp 3497 } 3498 3499 func (o ListUintOption) IsDefined() bool { 3500 // true if the list is not empty 3501 if len(o) > 0 { 3502 return true 3503 } 3504 return false 3505 } 3506 3507 type Uint16Option struct { 3508 Source string 3509 Defined bool 3510 Value uint16 3511 } 3512 3513 func NewUint16Option(dflt uint16) Uint16Option { 3514 return Uint16Option{ 3515 Source: "default", 3516 Defined: true, 3517 Value: dflt, 3518 } 3519 } 3520 3521 func (o Uint16Option) IsDefined() bool { 3522 return o.Defined 3523 } 3524 3525 func (o *Uint16Option) SetSource(source string) { 3526 o.Source = source 3527 } 3528 3529 func (o *Uint16Option) GetSource() string { 3530 return o.Source 3531 } 3532 3533 func (o Uint16Option) GetValue() interface{} { 3534 return o.Value 3535 } 3536 3537 // This is useful with kingpin option parser 3538 func (o *Uint16Option) Set(s string) error { 3539 err := convertString(s, &o.Value) 3540 if err != nil { 3541 return err 3542 } 3543 o.Source = "override" 3544 o.Defined = true 3545 return nil 3546 } 3547 3548 // This is useful with survey prompting library 3549 func (o *Uint16Option) WriteAnswer(name string, value interface{}) error { 3550 if v, ok := value.(uint16); ok { 3551 o.Value = v 3552 o.Defined = true 3553 o.Source = "prompt" 3554 return nil 3555 } 3556 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 3557 } 3558 3559 func (o *Uint16Option) SetValue(v interface{}) error { 3560 if val, ok := v.(uint16); ok { 3561 o.Value = val 3562 o.Defined = true 3563 return nil 3564 } 3565 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 3566 } 3567 3568 func (o *Uint16Option) UnmarshalYAML(unmarshal func(interface{}) error) error { 3569 if err := unmarshal(&o.Value); err != nil { 3570 return err 3571 } 3572 o.Source = "yaml" 3573 o.Defined = true 3574 return nil 3575 } 3576 3577 func (o *Uint16Option) UnmarshalJSON(b []byte) error { 3578 if err := json.Unmarshal(b, &o.Value); err != nil { 3579 return err 3580 } 3581 o.Source = "json" 3582 o.Defined = true 3583 return nil 3584 } 3585 3586 func (o Uint16Option) MarshalYAML() (interface{}, error) { 3587 if StringifyValue { 3588 return o.Value, nil 3589 } 3590 // need a copy of this struct without the MarshalYAML interface attached 3591 return struct { 3592 Value uint16 3593 Source string 3594 Defined bool 3595 }{ 3596 Value: o.Value, 3597 Source: o.Source, 3598 Defined: o.Defined, 3599 }, nil 3600 } 3601 3602 func (o Uint16Option) MarshalJSON() ([]byte, error) { 3603 if StringifyValue { 3604 return json.Marshal(o.Value) 3605 } 3606 // need a copy of this struct without the MarshalJSON interface attached 3607 return json.Marshal(struct { 3608 Value uint16 3609 Source string 3610 Defined bool 3611 }{ 3612 Value: o.Value, 3613 Source: o.Source, 3614 Defined: o.Defined, 3615 }) 3616 } 3617 3618 // String is required for kingpin to generate usage with this datatype 3619 func (o Uint16Option) String() string { 3620 if StringifyValue { 3621 return fmt.Sprintf("%v", o.Value) 3622 } 3623 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 3624 } 3625 3626 type MapUint16Option map[string]Uint16Option 3627 3628 // Set is required for kingpin interfaces to allow command line params 3629 // to be set to our map datatype 3630 func (o *MapUint16Option) Set(value string) error { 3631 parts := stringMapRegex.Split(value, 2) 3632 if len(parts) != 2 { 3633 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 3634 } 3635 val := Uint16Option{} 3636 val.Set(parts[1]) 3637 (*o)[parts[0]] = val 3638 return nil 3639 } 3640 3641 // IsCumulative is required for kingpin interfaces to allow multiple values 3642 // to be set on the data structure. 3643 func (o MapUint16Option) IsCumulative() bool { 3644 return true 3645 } 3646 3647 // String is required for kingpin to generate usage with this datatype 3648 func (o MapUint16Option) String() string { 3649 return fmt.Sprintf("%v", map[string]Uint16Option(o)) 3650 } 3651 3652 func (o MapUint16Option) Map() map[string]uint16 { 3653 tmp := map[string]uint16{} 3654 for k, v := range o { 3655 tmp[k] = v.Value 3656 } 3657 return tmp 3658 } 3659 3660 // This is useful with survey prompting library 3661 func (o *MapUint16Option) WriteAnswer(name string, value interface{}) error { 3662 tmp := Uint16Option{} 3663 if v, ok := value.(uint16); ok { 3664 tmp.Value = v 3665 tmp.Defined = true 3666 tmp.Source = "prompt" 3667 (*o)[name] = tmp 3668 return nil 3669 } 3670 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 3671 } 3672 3673 func (o MapUint16Option) IsDefined() bool { 3674 // true if the map has any keys 3675 if len(o) > 0 { 3676 return true 3677 } 3678 return false 3679 } 3680 3681 type ListUint16Option []Uint16Option 3682 3683 // Set is required for kingpin interfaces to allow command line params 3684 // to be set to our map datatype 3685 func (o *ListUint16Option) Set(value string) error { 3686 val := Uint16Option{} 3687 val.Set(value) 3688 *o = append(*o, val) 3689 return nil 3690 } 3691 3692 // This is useful with survey prompting library 3693 func (o *ListUint16Option) WriteAnswer(name string, value interface{}) error { 3694 tmp := Uint16Option{} 3695 if v, ok := value.(uint16); ok { 3696 tmp.Value = v 3697 tmp.Defined = true 3698 tmp.Source = "prompt" 3699 *o = append(*o, tmp) 3700 return nil 3701 } 3702 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 3703 } 3704 3705 // IsCumulative is required for kingpin interfaces to allow multiple values 3706 // to be set on the data structure. 3707 func (o ListUint16Option) IsCumulative() bool { 3708 return true 3709 } 3710 3711 // String is required for kingpin to generate usage with this datatype 3712 func (o ListUint16Option) String() string { 3713 return fmt.Sprintf("%v", []Uint16Option(o)) 3714 } 3715 3716 func (o ListUint16Option) Append(values ...uint16) ListUint16Option { 3717 results := o 3718 for _, val := range values { 3719 results = append(results, NewUint16Option(val)) 3720 } 3721 return results 3722 } 3723 3724 func (o ListUint16Option) Slice() []uint16 { 3725 tmp := []uint16{} 3726 for _, elem := range o { 3727 tmp = append(tmp, elem.Value) 3728 } 3729 return tmp 3730 } 3731 3732 func (o ListUint16Option) IsDefined() bool { 3733 // true if the list is not empty 3734 if len(o) > 0 { 3735 return true 3736 } 3737 return false 3738 } 3739 3740 type Uint32Option struct { 3741 Source string 3742 Defined bool 3743 Value uint32 3744 } 3745 3746 func NewUint32Option(dflt uint32) Uint32Option { 3747 return Uint32Option{ 3748 Source: "default", 3749 Defined: true, 3750 Value: dflt, 3751 } 3752 } 3753 3754 func (o Uint32Option) IsDefined() bool { 3755 return o.Defined 3756 } 3757 3758 func (o *Uint32Option) SetSource(source string) { 3759 o.Source = source 3760 } 3761 3762 func (o *Uint32Option) GetSource() string { 3763 return o.Source 3764 } 3765 3766 func (o Uint32Option) GetValue() interface{} { 3767 return o.Value 3768 } 3769 3770 // This is useful with kingpin option parser 3771 func (o *Uint32Option) Set(s string) error { 3772 err := convertString(s, &o.Value) 3773 if err != nil { 3774 return err 3775 } 3776 o.Source = "override" 3777 o.Defined = true 3778 return nil 3779 } 3780 3781 // This is useful with survey prompting library 3782 func (o *Uint32Option) WriteAnswer(name string, value interface{}) error { 3783 if v, ok := value.(uint32); ok { 3784 o.Value = v 3785 o.Defined = true 3786 o.Source = "prompt" 3787 return nil 3788 } 3789 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 3790 } 3791 3792 func (o *Uint32Option) SetValue(v interface{}) error { 3793 if val, ok := v.(uint32); ok { 3794 o.Value = val 3795 o.Defined = true 3796 return nil 3797 } 3798 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 3799 } 3800 3801 func (o *Uint32Option) UnmarshalYAML(unmarshal func(interface{}) error) error { 3802 if err := unmarshal(&o.Value); err != nil { 3803 return err 3804 } 3805 o.Source = "yaml" 3806 o.Defined = true 3807 return nil 3808 } 3809 3810 func (o *Uint32Option) UnmarshalJSON(b []byte) error { 3811 if err := json.Unmarshal(b, &o.Value); err != nil { 3812 return err 3813 } 3814 o.Source = "json" 3815 o.Defined = true 3816 return nil 3817 } 3818 3819 func (o Uint32Option) MarshalYAML() (interface{}, error) { 3820 if StringifyValue { 3821 return o.Value, nil 3822 } 3823 // need a copy of this struct without the MarshalYAML interface attached 3824 return struct { 3825 Value uint32 3826 Source string 3827 Defined bool 3828 }{ 3829 Value: o.Value, 3830 Source: o.Source, 3831 Defined: o.Defined, 3832 }, nil 3833 } 3834 3835 func (o Uint32Option) MarshalJSON() ([]byte, error) { 3836 if StringifyValue { 3837 return json.Marshal(o.Value) 3838 } 3839 // need a copy of this struct without the MarshalJSON interface attached 3840 return json.Marshal(struct { 3841 Value uint32 3842 Source string 3843 Defined bool 3844 }{ 3845 Value: o.Value, 3846 Source: o.Source, 3847 Defined: o.Defined, 3848 }) 3849 } 3850 3851 // String is required for kingpin to generate usage with this datatype 3852 func (o Uint32Option) String() string { 3853 if StringifyValue { 3854 return fmt.Sprintf("%v", o.Value) 3855 } 3856 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 3857 } 3858 3859 type MapUint32Option map[string]Uint32Option 3860 3861 // Set is required for kingpin interfaces to allow command line params 3862 // to be set to our map datatype 3863 func (o *MapUint32Option) Set(value string) error { 3864 parts := stringMapRegex.Split(value, 2) 3865 if len(parts) != 2 { 3866 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 3867 } 3868 val := Uint32Option{} 3869 val.Set(parts[1]) 3870 (*o)[parts[0]] = val 3871 return nil 3872 } 3873 3874 // IsCumulative is required for kingpin interfaces to allow multiple values 3875 // to be set on the data structure. 3876 func (o MapUint32Option) IsCumulative() bool { 3877 return true 3878 } 3879 3880 // String is required for kingpin to generate usage with this datatype 3881 func (o MapUint32Option) String() string { 3882 return fmt.Sprintf("%v", map[string]Uint32Option(o)) 3883 } 3884 3885 func (o MapUint32Option) Map() map[string]uint32 { 3886 tmp := map[string]uint32{} 3887 for k, v := range o { 3888 tmp[k] = v.Value 3889 } 3890 return tmp 3891 } 3892 3893 // This is useful with survey prompting library 3894 func (o *MapUint32Option) WriteAnswer(name string, value interface{}) error { 3895 tmp := Uint32Option{} 3896 if v, ok := value.(uint32); ok { 3897 tmp.Value = v 3898 tmp.Defined = true 3899 tmp.Source = "prompt" 3900 (*o)[name] = tmp 3901 return nil 3902 } 3903 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 3904 } 3905 3906 func (o MapUint32Option) IsDefined() bool { 3907 // true if the map has any keys 3908 if len(o) > 0 { 3909 return true 3910 } 3911 return false 3912 } 3913 3914 type ListUint32Option []Uint32Option 3915 3916 // Set is required for kingpin interfaces to allow command line params 3917 // to be set to our map datatype 3918 func (o *ListUint32Option) Set(value string) error { 3919 val := Uint32Option{} 3920 val.Set(value) 3921 *o = append(*o, val) 3922 return nil 3923 } 3924 3925 // This is useful with survey prompting library 3926 func (o *ListUint32Option) WriteAnswer(name string, value interface{}) error { 3927 tmp := Uint32Option{} 3928 if v, ok := value.(uint32); ok { 3929 tmp.Value = v 3930 tmp.Defined = true 3931 tmp.Source = "prompt" 3932 *o = append(*o, tmp) 3933 return nil 3934 } 3935 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 3936 } 3937 3938 // IsCumulative is required for kingpin interfaces to allow multiple values 3939 // to be set on the data structure. 3940 func (o ListUint32Option) IsCumulative() bool { 3941 return true 3942 } 3943 3944 // String is required for kingpin to generate usage with this datatype 3945 func (o ListUint32Option) String() string { 3946 return fmt.Sprintf("%v", []Uint32Option(o)) 3947 } 3948 3949 func (o ListUint32Option) Append(values ...uint32) ListUint32Option { 3950 results := o 3951 for _, val := range values { 3952 results = append(results, NewUint32Option(val)) 3953 } 3954 return results 3955 } 3956 3957 func (o ListUint32Option) Slice() []uint32 { 3958 tmp := []uint32{} 3959 for _, elem := range o { 3960 tmp = append(tmp, elem.Value) 3961 } 3962 return tmp 3963 } 3964 3965 func (o ListUint32Option) IsDefined() bool { 3966 // true if the list is not empty 3967 if len(o) > 0 { 3968 return true 3969 } 3970 return false 3971 } 3972 3973 type Uint64Option struct { 3974 Source string 3975 Defined bool 3976 Value uint64 3977 } 3978 3979 func NewUint64Option(dflt uint64) Uint64Option { 3980 return Uint64Option{ 3981 Source: "default", 3982 Defined: true, 3983 Value: dflt, 3984 } 3985 } 3986 3987 func (o Uint64Option) IsDefined() bool { 3988 return o.Defined 3989 } 3990 3991 func (o *Uint64Option) SetSource(source string) { 3992 o.Source = source 3993 } 3994 3995 func (o *Uint64Option) GetSource() string { 3996 return o.Source 3997 } 3998 3999 func (o Uint64Option) GetValue() interface{} { 4000 return o.Value 4001 } 4002 4003 // This is useful with kingpin option parser 4004 func (o *Uint64Option) Set(s string) error { 4005 err := convertString(s, &o.Value) 4006 if err != nil { 4007 return err 4008 } 4009 o.Source = "override" 4010 o.Defined = true 4011 return nil 4012 } 4013 4014 // This is useful with survey prompting library 4015 func (o *Uint64Option) WriteAnswer(name string, value interface{}) error { 4016 if v, ok := value.(uint64); ok { 4017 o.Value = v 4018 o.Defined = true 4019 o.Source = "prompt" 4020 return nil 4021 } 4022 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 4023 } 4024 4025 func (o *Uint64Option) SetValue(v interface{}) error { 4026 if val, ok := v.(uint64); ok { 4027 o.Value = val 4028 o.Defined = true 4029 return nil 4030 } 4031 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 4032 } 4033 4034 func (o *Uint64Option) UnmarshalYAML(unmarshal func(interface{}) error) error { 4035 if err := unmarshal(&o.Value); err != nil { 4036 return err 4037 } 4038 o.Source = "yaml" 4039 o.Defined = true 4040 return nil 4041 } 4042 4043 func (o *Uint64Option) UnmarshalJSON(b []byte) error { 4044 if err := json.Unmarshal(b, &o.Value); err != nil { 4045 return err 4046 } 4047 o.Source = "json" 4048 o.Defined = true 4049 return nil 4050 } 4051 4052 func (o Uint64Option) MarshalYAML() (interface{}, error) { 4053 if StringifyValue { 4054 return o.Value, nil 4055 } 4056 // need a copy of this struct without the MarshalYAML interface attached 4057 return struct { 4058 Value uint64 4059 Source string 4060 Defined bool 4061 }{ 4062 Value: o.Value, 4063 Source: o.Source, 4064 Defined: o.Defined, 4065 }, nil 4066 } 4067 4068 func (o Uint64Option) MarshalJSON() ([]byte, error) { 4069 if StringifyValue { 4070 return json.Marshal(o.Value) 4071 } 4072 // need a copy of this struct without the MarshalJSON interface attached 4073 return json.Marshal(struct { 4074 Value uint64 4075 Source string 4076 Defined bool 4077 }{ 4078 Value: o.Value, 4079 Source: o.Source, 4080 Defined: o.Defined, 4081 }) 4082 } 4083 4084 // String is required for kingpin to generate usage with this datatype 4085 func (o Uint64Option) String() string { 4086 if StringifyValue { 4087 return fmt.Sprintf("%v", o.Value) 4088 } 4089 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 4090 } 4091 4092 type MapUint64Option map[string]Uint64Option 4093 4094 // Set is required for kingpin interfaces to allow command line params 4095 // to be set to our map datatype 4096 func (o *MapUint64Option) Set(value string) error { 4097 parts := stringMapRegex.Split(value, 2) 4098 if len(parts) != 2 { 4099 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 4100 } 4101 val := Uint64Option{} 4102 val.Set(parts[1]) 4103 (*o)[parts[0]] = val 4104 return nil 4105 } 4106 4107 // IsCumulative is required for kingpin interfaces to allow multiple values 4108 // to be set on the data structure. 4109 func (o MapUint64Option) IsCumulative() bool { 4110 return true 4111 } 4112 4113 // String is required for kingpin to generate usage with this datatype 4114 func (o MapUint64Option) String() string { 4115 return fmt.Sprintf("%v", map[string]Uint64Option(o)) 4116 } 4117 4118 func (o MapUint64Option) Map() map[string]uint64 { 4119 tmp := map[string]uint64{} 4120 for k, v := range o { 4121 tmp[k] = v.Value 4122 } 4123 return tmp 4124 } 4125 4126 // This is useful with survey prompting library 4127 func (o *MapUint64Option) WriteAnswer(name string, value interface{}) error { 4128 tmp := Uint64Option{} 4129 if v, ok := value.(uint64); ok { 4130 tmp.Value = v 4131 tmp.Defined = true 4132 tmp.Source = "prompt" 4133 (*o)[name] = tmp 4134 return nil 4135 } 4136 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 4137 } 4138 4139 func (o MapUint64Option) IsDefined() bool { 4140 // true if the map has any keys 4141 if len(o) > 0 { 4142 return true 4143 } 4144 return false 4145 } 4146 4147 type ListUint64Option []Uint64Option 4148 4149 // Set is required for kingpin interfaces to allow command line params 4150 // to be set to our map datatype 4151 func (o *ListUint64Option) Set(value string) error { 4152 val := Uint64Option{} 4153 val.Set(value) 4154 *o = append(*o, val) 4155 return nil 4156 } 4157 4158 // This is useful with survey prompting library 4159 func (o *ListUint64Option) WriteAnswer(name string, value interface{}) error { 4160 tmp := Uint64Option{} 4161 if v, ok := value.(uint64); ok { 4162 tmp.Value = v 4163 tmp.Defined = true 4164 tmp.Source = "prompt" 4165 *o = append(*o, tmp) 4166 return nil 4167 } 4168 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 4169 } 4170 4171 // IsCumulative is required for kingpin interfaces to allow multiple values 4172 // to be set on the data structure. 4173 func (o ListUint64Option) IsCumulative() bool { 4174 return true 4175 } 4176 4177 // String is required for kingpin to generate usage with this datatype 4178 func (o ListUint64Option) String() string { 4179 return fmt.Sprintf("%v", []Uint64Option(o)) 4180 } 4181 4182 func (o ListUint64Option) Append(values ...uint64) ListUint64Option { 4183 results := o 4184 for _, val := range values { 4185 results = append(results, NewUint64Option(val)) 4186 } 4187 return results 4188 } 4189 4190 func (o ListUint64Option) Slice() []uint64 { 4191 tmp := []uint64{} 4192 for _, elem := range o { 4193 tmp = append(tmp, elem.Value) 4194 } 4195 return tmp 4196 } 4197 4198 func (o ListUint64Option) IsDefined() bool { 4199 // true if the list is not empty 4200 if len(o) > 0 { 4201 return true 4202 } 4203 return false 4204 } 4205 4206 type Uint8Option struct { 4207 Source string 4208 Defined bool 4209 Value uint8 4210 } 4211 4212 func NewUint8Option(dflt uint8) Uint8Option { 4213 return Uint8Option{ 4214 Source: "default", 4215 Defined: true, 4216 Value: dflt, 4217 } 4218 } 4219 4220 func (o Uint8Option) IsDefined() bool { 4221 return o.Defined 4222 } 4223 4224 func (o *Uint8Option) SetSource(source string) { 4225 o.Source = source 4226 } 4227 4228 func (o *Uint8Option) GetSource() string { 4229 return o.Source 4230 } 4231 4232 func (o Uint8Option) GetValue() interface{} { 4233 return o.Value 4234 } 4235 4236 // This is useful with kingpin option parser 4237 func (o *Uint8Option) Set(s string) error { 4238 err := convertString(s, &o.Value) 4239 if err != nil { 4240 return err 4241 } 4242 o.Source = "override" 4243 o.Defined = true 4244 return nil 4245 } 4246 4247 // This is useful with survey prompting library 4248 func (o *Uint8Option) WriteAnswer(name string, value interface{}) error { 4249 if v, ok := value.(uint8); ok { 4250 o.Value = v 4251 o.Defined = true 4252 o.Source = "prompt" 4253 return nil 4254 } 4255 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 4256 } 4257 4258 func (o *Uint8Option) SetValue(v interface{}) error { 4259 if val, ok := v.(uint8); ok { 4260 o.Value = val 4261 o.Defined = true 4262 return nil 4263 } 4264 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 4265 } 4266 4267 func (o *Uint8Option) UnmarshalYAML(unmarshal func(interface{}) error) error { 4268 if err := unmarshal(&o.Value); err != nil { 4269 return err 4270 } 4271 o.Source = "yaml" 4272 o.Defined = true 4273 return nil 4274 } 4275 4276 func (o *Uint8Option) UnmarshalJSON(b []byte) error { 4277 if err := json.Unmarshal(b, &o.Value); err != nil { 4278 return err 4279 } 4280 o.Source = "json" 4281 o.Defined = true 4282 return nil 4283 } 4284 4285 func (o Uint8Option) MarshalYAML() (interface{}, error) { 4286 if StringifyValue { 4287 return o.Value, nil 4288 } 4289 // need a copy of this struct without the MarshalYAML interface attached 4290 return struct { 4291 Value uint8 4292 Source string 4293 Defined bool 4294 }{ 4295 Value: o.Value, 4296 Source: o.Source, 4297 Defined: o.Defined, 4298 }, nil 4299 } 4300 4301 func (o Uint8Option) MarshalJSON() ([]byte, error) { 4302 if StringifyValue { 4303 return json.Marshal(o.Value) 4304 } 4305 // need a copy of this struct without the MarshalJSON interface attached 4306 return json.Marshal(struct { 4307 Value uint8 4308 Source string 4309 Defined bool 4310 }{ 4311 Value: o.Value, 4312 Source: o.Source, 4313 Defined: o.Defined, 4314 }) 4315 } 4316 4317 // String is required for kingpin to generate usage with this datatype 4318 func (o Uint8Option) String() string { 4319 if StringifyValue { 4320 return fmt.Sprintf("%v", o.Value) 4321 } 4322 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 4323 } 4324 4325 type MapUint8Option map[string]Uint8Option 4326 4327 // Set is required for kingpin interfaces to allow command line params 4328 // to be set to our map datatype 4329 func (o *MapUint8Option) Set(value string) error { 4330 parts := stringMapRegex.Split(value, 2) 4331 if len(parts) != 2 { 4332 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 4333 } 4334 val := Uint8Option{} 4335 val.Set(parts[1]) 4336 (*o)[parts[0]] = val 4337 return nil 4338 } 4339 4340 // IsCumulative is required for kingpin interfaces to allow multiple values 4341 // to be set on the data structure. 4342 func (o MapUint8Option) IsCumulative() bool { 4343 return true 4344 } 4345 4346 // String is required for kingpin to generate usage with this datatype 4347 func (o MapUint8Option) String() string { 4348 return fmt.Sprintf("%v", map[string]Uint8Option(o)) 4349 } 4350 4351 func (o MapUint8Option) Map() map[string]uint8 { 4352 tmp := map[string]uint8{} 4353 for k, v := range o { 4354 tmp[k] = v.Value 4355 } 4356 return tmp 4357 } 4358 4359 // This is useful with survey prompting library 4360 func (o *MapUint8Option) WriteAnswer(name string, value interface{}) error { 4361 tmp := Uint8Option{} 4362 if v, ok := value.(uint8); ok { 4363 tmp.Value = v 4364 tmp.Defined = true 4365 tmp.Source = "prompt" 4366 (*o)[name] = tmp 4367 return nil 4368 } 4369 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 4370 } 4371 4372 func (o MapUint8Option) IsDefined() bool { 4373 // true if the map has any keys 4374 if len(o) > 0 { 4375 return true 4376 } 4377 return false 4378 } 4379 4380 type ListUint8Option []Uint8Option 4381 4382 // Set is required for kingpin interfaces to allow command line params 4383 // to be set to our map datatype 4384 func (o *ListUint8Option) Set(value string) error { 4385 val := Uint8Option{} 4386 val.Set(value) 4387 *o = append(*o, val) 4388 return nil 4389 } 4390 4391 // This is useful with survey prompting library 4392 func (o *ListUint8Option) WriteAnswer(name string, value interface{}) error { 4393 tmp := Uint8Option{} 4394 if v, ok := value.(uint8); ok { 4395 tmp.Value = v 4396 tmp.Defined = true 4397 tmp.Source = "prompt" 4398 *o = append(*o, tmp) 4399 return nil 4400 } 4401 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 4402 } 4403 4404 // IsCumulative is required for kingpin interfaces to allow multiple values 4405 // to be set on the data structure. 4406 func (o ListUint8Option) IsCumulative() bool { 4407 return true 4408 } 4409 4410 // String is required for kingpin to generate usage with this datatype 4411 func (o ListUint8Option) String() string { 4412 return fmt.Sprintf("%v", []Uint8Option(o)) 4413 } 4414 4415 func (o ListUint8Option) Append(values ...uint8) ListUint8Option { 4416 results := o 4417 for _, val := range values { 4418 results = append(results, NewUint8Option(val)) 4419 } 4420 return results 4421 } 4422 4423 func (o ListUint8Option) Slice() []uint8 { 4424 tmp := []uint8{} 4425 for _, elem := range o { 4426 tmp = append(tmp, elem.Value) 4427 } 4428 return tmp 4429 } 4430 4431 func (o ListUint8Option) IsDefined() bool { 4432 // true if the list is not empty 4433 if len(o) > 0 { 4434 return true 4435 } 4436 return false 4437 } 4438 4439 type UintptrOption struct { 4440 Source string 4441 Defined bool 4442 Value uintptr 4443 } 4444 4445 func NewUintptrOption(dflt uintptr) UintptrOption { 4446 return UintptrOption{ 4447 Source: "default", 4448 Defined: true, 4449 Value: dflt, 4450 } 4451 } 4452 4453 func (o UintptrOption) IsDefined() bool { 4454 return o.Defined 4455 } 4456 4457 func (o *UintptrOption) SetSource(source string) { 4458 o.Source = source 4459 } 4460 4461 func (o *UintptrOption) GetSource() string { 4462 return o.Source 4463 } 4464 4465 func (o UintptrOption) GetValue() interface{} { 4466 return o.Value 4467 } 4468 4469 // This is useful with kingpin option parser 4470 func (o *UintptrOption) Set(s string) error { 4471 err := convertString(s, &o.Value) 4472 if err != nil { 4473 return err 4474 } 4475 o.Source = "override" 4476 o.Defined = true 4477 return nil 4478 } 4479 4480 // This is useful with survey prompting library 4481 func (o *UintptrOption) WriteAnswer(name string, value interface{}) error { 4482 if v, ok := value.(uintptr); ok { 4483 o.Value = v 4484 o.Defined = true 4485 o.Source = "prompt" 4486 return nil 4487 } 4488 return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) 4489 } 4490 4491 func (o *UintptrOption) SetValue(v interface{}) error { 4492 if val, ok := v.(uintptr); ok { 4493 o.Value = val 4494 o.Defined = true 4495 return nil 4496 } 4497 return fmt.Errorf("Got %T expected %T type: %v", v, o.Value, v) 4498 } 4499 4500 func (o *UintptrOption) UnmarshalYAML(unmarshal func(interface{}) error) error { 4501 if err := unmarshal(&o.Value); err != nil { 4502 return err 4503 } 4504 o.Source = "yaml" 4505 o.Defined = true 4506 return nil 4507 } 4508 4509 func (o *UintptrOption) UnmarshalJSON(b []byte) error { 4510 if err := json.Unmarshal(b, &o.Value); err != nil { 4511 return err 4512 } 4513 o.Source = "json" 4514 o.Defined = true 4515 return nil 4516 } 4517 4518 func (o UintptrOption) MarshalYAML() (interface{}, error) { 4519 if StringifyValue { 4520 return o.Value, nil 4521 } 4522 // need a copy of this struct without the MarshalYAML interface attached 4523 return struct { 4524 Value uintptr 4525 Source string 4526 Defined bool 4527 }{ 4528 Value: o.Value, 4529 Source: o.Source, 4530 Defined: o.Defined, 4531 }, nil 4532 } 4533 4534 func (o UintptrOption) MarshalJSON() ([]byte, error) { 4535 if StringifyValue { 4536 return json.Marshal(o.Value) 4537 } 4538 // need a copy of this struct without the MarshalJSON interface attached 4539 return json.Marshal(struct { 4540 Value uintptr 4541 Source string 4542 Defined bool 4543 }{ 4544 Value: o.Value, 4545 Source: o.Source, 4546 Defined: o.Defined, 4547 }) 4548 } 4549 4550 // String is required for kingpin to generate usage with this datatype 4551 func (o UintptrOption) String() string { 4552 if StringifyValue { 4553 return fmt.Sprintf("%v", o.Value) 4554 } 4555 return fmt.Sprintf("{Source:%s Defined:%t Value:%v}", o.Source, o.Defined, o.Value) 4556 } 4557 4558 type MapUintptrOption map[string]UintptrOption 4559 4560 // Set is required for kingpin interfaces to allow command line params 4561 // to be set to our map datatype 4562 func (o *MapUintptrOption) Set(value string) error { 4563 parts := stringMapRegex.Split(value, 2) 4564 if len(parts) != 2 { 4565 return fmt.Errorf("expected KEY=VALUE got '%s'", value) 4566 } 4567 val := UintptrOption{} 4568 val.Set(parts[1]) 4569 (*o)[parts[0]] = val 4570 return nil 4571 } 4572 4573 // IsCumulative is required for kingpin interfaces to allow multiple values 4574 // to be set on the data structure. 4575 func (o MapUintptrOption) IsCumulative() bool { 4576 return true 4577 } 4578 4579 // String is required for kingpin to generate usage with this datatype 4580 func (o MapUintptrOption) String() string { 4581 return fmt.Sprintf("%v", map[string]UintptrOption(o)) 4582 } 4583 4584 func (o MapUintptrOption) Map() map[string]uintptr { 4585 tmp := map[string]uintptr{} 4586 for k, v := range o { 4587 tmp[k] = v.Value 4588 } 4589 return tmp 4590 } 4591 4592 // This is useful with survey prompting library 4593 func (o *MapUintptrOption) WriteAnswer(name string, value interface{}) error { 4594 tmp := UintptrOption{} 4595 if v, ok := value.(uintptr); ok { 4596 tmp.Value = v 4597 tmp.Defined = true 4598 tmp.Source = "prompt" 4599 (*o)[name] = tmp 4600 return nil 4601 } 4602 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 4603 } 4604 4605 func (o MapUintptrOption) IsDefined() bool { 4606 // true if the map has any keys 4607 if len(o) > 0 { 4608 return true 4609 } 4610 return false 4611 } 4612 4613 type ListUintptrOption []UintptrOption 4614 4615 // Set is required for kingpin interfaces to allow command line params 4616 // to be set to our map datatype 4617 func (o *ListUintptrOption) Set(value string) error { 4618 val := UintptrOption{} 4619 val.Set(value) 4620 *o = append(*o, val) 4621 return nil 4622 } 4623 4624 // This is useful with survey prompting library 4625 func (o *ListUintptrOption) WriteAnswer(name string, value interface{}) error { 4626 tmp := UintptrOption{} 4627 if v, ok := value.(uintptr); ok { 4628 tmp.Value = v 4629 tmp.Defined = true 4630 tmp.Source = "prompt" 4631 *o = append(*o, tmp) 4632 return nil 4633 } 4634 return fmt.Errorf("Got %T expected %T type: %v", value, tmp.Value, value) 4635 } 4636 4637 // IsCumulative is required for kingpin interfaces to allow multiple values 4638 // to be set on the data structure. 4639 func (o ListUintptrOption) IsCumulative() bool { 4640 return true 4641 } 4642 4643 // String is required for kingpin to generate usage with this datatype 4644 func (o ListUintptrOption) String() string { 4645 return fmt.Sprintf("%v", []UintptrOption(o)) 4646 } 4647 4648 func (o ListUintptrOption) Append(values ...uintptr) ListUintptrOption { 4649 results := o 4650 for _, val := range values { 4651 results = append(results, NewUintptrOption(val)) 4652 } 4653 return results 4654 } 4655 4656 func (o ListUintptrOption) Slice() []uintptr { 4657 tmp := []uintptr{} 4658 for _, elem := range o { 4659 tmp = append(tmp, elem.Value) 4660 } 4661 return tmp 4662 } 4663 4664 func (o ListUintptrOption) IsDefined() bool { 4665 // true if the list is not empty 4666 if len(o) > 0 { 4667 return true 4668 } 4669 return false 4670 }