| 1 | // Support for Miller regression testing. Originally bash scripts; ported to Go |
| 2 | // for ease of Windows-native testing. |
| 3 | |
| 4 | package auxentsscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/ |
| 5 | |
| 6 | import ( |
| 7 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 8 | "osscip-go gomod github.com/golang/go/src go1.25.0 os/" |
| 9 | ) |
| 10 | |
| 11 | // tAuxMain is a function-pointer type for the entrypoint handler for a given auxent, |
| 12 | // such as 'help' or 'regtest'. |
| 13 | type tAuxMainscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/tAuxMain# func(args []string) int |
| 14 | |
| 15 | type tAuxLookupEntryscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/tAuxLookupEntry# struct { |
| 16 | namescip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/tAuxLookupEntry#name. string |
| 17 | mainscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/tAuxLookupEntry#main. tAuxMainscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/tAuxMain# |
| 18 | } |
| 19 | |
| 20 | // _AUX_LOOKUP_TABLE is the lookup table for auxents. We get a Golang |
| 21 | // "initialization loop" if this is defined statically. So, we use a "package |
| 22 | // init" function. |
| 23 | var _AUX_LOOKUP_TABLEscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/_AUX_LOOKUP_TABLE. = []tAuxLookupEntryscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/tAuxLookupEntry#{} |
| 24 | |
| 25 | func initscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/init().() { |
| 26 | _AUX_LOOKUP_TABLEscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/_AUX_LOOKUP_TABLE. = []tAuxLookupEntryscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/tAuxLookupEntry#{ |
| 27 | {"aux-list", auxListMainscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/auxListMain().}, |
| 28 | {"hex", hexMainscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/hexMain().}, |
| 29 | {"lecat", lecatMainscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/lecatMain().}, |
| 30 | {"termcvt", termcvtMainscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/termcvtMain().}, |
| 31 | {"unhex", unhexMainscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/unhexMain().}, |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | // Dispatch is called from Miller main. Here we indicate if argv[1] is handled |
| 36 | // by us, or not. If so, we handle it and exit, not returning control to Miller |
| 37 | // main. |
| 38 | func Dispatchscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/Dispatch().(args []string) { |
| 39 | if len(args) < 2 { |
| 40 | return |
| 41 | } |
| 42 | verb := args[1] |
| 43 | |
| 44 | for _, entry := range _AUX_LOOKUP_TABLEscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/_AUX_LOOKUP_TABLE. { |
| 45 | if verb == entry.namescip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/tAuxLookupEntry#name. { |
| 46 | osscip-go gomod github.com/golang/go/src go1.25.0 os/.Exitscip-go gomod github.com/golang/go/src go1.25.0 os/Exit().(entry.mainscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/tAuxLookupEntry#main.(args)) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | // Else, return control to main for the rest of Miller. |
| 51 | } |
| 52 | |
| 53 | // auxListMain is the handler for 'mlr aux-list'. |
| 54 | func auxListMainscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/auxListMain().(args []string) int { |
| 55 | ShowAuxEntriesscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/ShowAuxEntries().(osscip-go gomod github.com/golang/go/src go1.25.0 os/.Stdoutscip-go gomod github.com/golang/go/src go1.25.0 os/Stdout.) |
| 56 | return 0 |
| 57 | } |
| 58 | |
| 59 | // ShowAuxEntries is a symbol is exported for 'mlr --help'. |
| 60 | func ShowAuxEntriesscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/ShowAuxEntries().(o *osscip-go gomod github.com/golang/go/src go1.25.0 os/.Filescip-go gomod github.com/golang/go/src go1.25.0 os/File#) { |
| 61 | fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintf().(o, "Available entries:\n") |
| 62 | for _, entry := range _AUX_LOOKUP_TABLEscip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/_AUX_LOOKUP_TABLE. { |
| 63 | fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintf().(o, " mlr %s\n", entry.namescip-go gomod github.com/johnkerl/miller/v6 . `github.com/johnkerl/miller/v6/pkg/auxents`/tAuxLookupEntry#name.) |
| 64 | } |
| 65 | |
| 66 | fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintf().(o, "For more information, please invoke mlr {subcommand} --help.\n") |
| 67 | } |