mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-22 18:06:52 +00:00
Export library code in pkg/ (#1391)
* Export library code in `pkg/` * new doc page
This commit is contained in:
parent
93b7c8eac0
commit
268a96d002
358 changed files with 1076 additions and 693 deletions
22
Makefile
22
Makefile
|
|
@ -30,25 +30,25 @@ install: build
|
|||
# ----------------------------------------------------------------
|
||||
# Unit tests (small number)
|
||||
unit-test ut: build
|
||||
go test github.com/johnkerl/miller/internal/pkg/...
|
||||
go test github.com/johnkerl/miller/pkg/...
|
||||
|
||||
ut-lib:build
|
||||
go test github.com/johnkerl/miller/internal/pkg/lib...
|
||||
go test github.com/johnkerl/miller/pkg/lib...
|
||||
ut-scan:build
|
||||
go test github.com/johnkerl/miller/internal/pkg/scan/...
|
||||
go test github.com/johnkerl/miller/pkg/scan/...
|
||||
ut-mlv:build
|
||||
go test github.com/johnkerl/miller/internal/pkg/mlrval/...
|
||||
go test github.com/johnkerl/miller/pkg/mlrval/...
|
||||
ut-bifs:build
|
||||
go test github.com/johnkerl/miller/internal/pkg/bifs/...
|
||||
go test github.com/johnkerl/miller/pkg/bifs/...
|
||||
ut-input:build
|
||||
go test github.com/johnkerl/miller/internal/pkg/input/...
|
||||
go test github.com/johnkerl/miller/pkg/input/...
|
||||
|
||||
bench:build
|
||||
go test -run=nonesuch -bench=. github.com/johnkerl/miller/internal/pkg/...
|
||||
go test -run=nonesuch -bench=. github.com/johnkerl/miller/pkg/...
|
||||
bench-mlv:build
|
||||
go test -run=nonesuch -bench=. github.com/johnkerl/miller/internal/pkg/mlrval/...
|
||||
go test -run=nonesuch -bench=. github.com/johnkerl/miller/pkg/mlrval/...
|
||||
bench-input:build
|
||||
go test -run=nonesuch -bench=. github.com/johnkerl/miller/internal/pkg/input/...
|
||||
go test -run=nonesuch -bench=. github.com/johnkerl/miller/pkg/input/...
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Regression tests (large number)
|
||||
|
|
@ -56,7 +56,7 @@ bench-input:build
|
|||
# See ./regression_test.go for information on how to get more details
|
||||
# for debugging. TL;DR is for CI jobs, we have 'go test -v'; for
|
||||
# interactive use, instead of 'go test -v' simply use 'mlr regtest
|
||||
# -vvv' or 'mlr regtest -s 20'. See also internal/pkg/terminals/regtest.
|
||||
# -vvv' or 'mlr regtest -s 20'. See also pkg/terminals/regtest.
|
||||
regression-test: build
|
||||
go test -v regression_test.go
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ regression-test: build
|
|||
# go fmt ./... finds experimental C files which we want to ignore.
|
||||
fmt format:
|
||||
-go fmt ./cmd/...
|
||||
-go fmt ./internal/pkg/...
|
||||
-go fmt ./pkg/...
|
||||
-go fmt ./regression_test.go
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -61,10 +61,10 @@ During the coding of Miller, I've been guided by the following:
|
|||
* Names of files, variables, functions, etc. should be fully spelled out (e.g. `NewEvaluableLeafNode`), except for a small number of most-used names where a longer name would cause unnecessary line-wraps (e.g. `Mlrval` instead of `MillerValue` since this appears very very often).
|
||||
* Code should not be too clever. This includes some reasonable amounts of code duplication from time to time, to keep things inline, rather than lasagna code.
|
||||
* Things should be transparent. For example, the `-v` in `mlr -n put -v '$y = 3 + 0.1 * $x'` shows you the abstract syntax tree derived from the DSL expression.
|
||||
* Comments should be robust with respect to reasonably anticipated changes. For example, one package should cross-link to another in its comments, but I try to avoid mentioning specific filenames too much in the comments and README files since these may change over time. I make an exception for stable points such as [cmd/mlr/main.go](./cmd/mlr/main.go), [mlr.bnf](./internal/pkg/parsing/mlr.bnf), [stream.go](./internal/pkg/stream/stream.go), etc.
|
||||
* Comments should be robust with respect to reasonably anticipated changes. For example, one package should cross-link to another in its comments, but I try to avoid mentioning specific filenames too much in the comments and README files since these may change over time. I make an exception for stable points such as [cmd/mlr/main.go](./cmd/mlr/main.go), [mlr.bnf](./pkg/parsing/mlr.bnf), [stream.go](./pkg/stream/stream.go), etc.
|
||||
* *Miller should be pleasant to write.*
|
||||
* It should be quick to answer the question *Did I just break anything?* -- hence `mlr regtest` functionality.
|
||||
* It should be quick to find out what to do next as you iteratively develop -- see for example [cst/README.md](./internal/pkg/dsl/cst/README.md).
|
||||
* It should be quick to find out what to do next as you iteratively develop -- see for example [cst/README.md](./pkg/dsl/cst/README.md).
|
||||
* *The language should be an asset, not a liability.*
|
||||
* One of the reasons I chose Go is that (personally anyway) I find it to be reasonably efficient, well-supported with standard libraries, straightforward, and fun. I hope you enjoy it as much as I have.
|
||||
|
||||
|
|
@ -83,10 +83,10 @@ sequence of key-value pairs. The basic **stream** operation is:
|
|||
|
||||
So, in broad overview, the key packages are:
|
||||
|
||||
* [internal/pkg/stream](./internal/pkg/stream) -- connect input -> transforms -> output via Go channels
|
||||
* [internal/pkg/input](./internal/pkg/input) -- read input records
|
||||
* [internal/pkg/transformers](./internal/pkg/transformers) -- transform input records to output records
|
||||
* [internal/pkg/output](./internal/pkg/output) -- write output records
|
||||
* [pkg/stream](./pkg/stream) -- connect input -> transforms -> output via Go channels
|
||||
* [pkg/input](./pkg/input) -- read input records
|
||||
* [pkg/transformers](./pkg/transformers) -- transform input records to output records
|
||||
* [pkg/output](./pkg/output) -- write output records
|
||||
* The rest are details to support this.
|
||||
|
||||
## Directory-structure details
|
||||
|
|
@ -98,7 +98,7 @@ So, in broad overview, the key packages are:
|
|||
* This package defines the grammar for Miller's domain-specific language (DSL) for the Miller `put` and `filter` verbs. And, GOCC is a joy to use. :)
|
||||
* It is used on the terms of its open-source license.
|
||||
* [golang.org/x/term](https://pkg.go.dev/golang.org/x/term):
|
||||
* Just a one-line Miller callsite for is-a-terminal checking for the [Miller REPL](./internal/pkg/terminals/repl/README.md).
|
||||
* Just a one-line Miller callsite for is-a-terminal checking for the [Miller REPL](./pkg/terminals/repl/README.md).
|
||||
* It is used on the terms of its open-source license.
|
||||
* See also [./go.mod](go.mod). Setup:
|
||||
* `go get github.com/goccmack/gocc`
|
||||
|
|
@ -106,22 +106,22 @@ So, in broad overview, the key packages are:
|
|||
|
||||
### Miller per se
|
||||
|
||||
* The main entry point is [cmd/mlr/main.go](./cmd/mlr/main.go); everything else in [internal/pkg](./internal/pkg).
|
||||
* [internal/pkg/entrypoint](./internal/pkg/entrypoint): All the usual contents of `main()` are here, for ease of testing.
|
||||
* [internal/pkg/platform](./internal/pkg/platform): Platform-dependent code, which as of early 2021 is the command-line parser. Handling single quotes and double quotes is different on Windows unless particular care is taken, which is what this package does.
|
||||
* [internal/pkg/lib](./internal/pkg/lib):
|
||||
* Implementation of the [`Mlrval`](./internal/pkg/types/mlrval.go) datatype which includes string/int/float/boolean/void/absent/error types. These are used for record values, as well as expression/variable values in the Miller `put`/`filter` DSL. See also below for more details.
|
||||
* [`Mlrmap`](./internal/pkg/types/mlrmap.go) is the sequence of key-value pairs which represents a Miller record. The key-lookup mechanism is optimized for Miller read/write usage patterns -- please see [mlrmap.go](./internal/pkg/types/mlrmap.go) for more details.
|
||||
* [`context`](./internal/pkg/types/context.go) supports AWK-like variables such as `FILENAME`, `NF`, `NR`, and so on.
|
||||
* [internal/pkg/cli](./internal/pkg/cli) is the flag-parsing logic for supporting Miller's command-line interface. When you type something like `mlr --icsv --ojson put '$sum = $a + $b' then filter '$sum > 1000' myfile.csv`, it's the CLI parser which makes it possible for Miller to construct a CSV record-reader, a transformer-chain of `put` then `filter`, and a JSON record-writer.
|
||||
* [internal/pkg/climain](./internal/pkg/climain) contains a layer which invokes `internal/pkg/cli`, which was split out to avoid a Go package-import cycle.
|
||||
* [internal/pkg/stream](./internal/pkg/stream) is as above -- it uses Go channels to pipe together file-reads, to record-reading/parsing, to a chain of record-transformers, to record-writing/formatting, to terminal standard output.
|
||||
* [internal/pkg/input](./internal/pkg/input) is as above -- one record-reader type per supported input file format, and a factory method.
|
||||
* [internal/pkg/output](./internal/pkg/output) is as above -- one record-writer type per supported output file format, and a factory method.
|
||||
* [internal/pkg/transformers](./internal/pkg/transformers) contains the abstract record-transformer interface datatype, as well as the Go-channel chaining mechanism for piping one transformer into the next. It also contains all the concrete record-transformers such as `cat`, `tac`, `sort`, `put`, and so on.
|
||||
* [internal/pkg/parsing](./internal/pkg/parsing) contains a single source file, `mlr.bnf`, which is the lexical/semantic grammar file for the Miller `put`/`filter` DSL using the GOCC framework. All subdirectories of `internal/pkg/parsing/` are autogen code created by GOCC's processing of `mlr.bnf`. If you need to edit `mlr.bnf`, please use [tools/build-dsl](./tools/build-dsl) to autogenerate Go code from it (using the GOCC tool). (This takes several minutes to run.)
|
||||
* [internal/pkg/dsl](./internal/pkg/dsl) contains [`ast_types.go`](internal/pkg/dsl/ast_types.go) which is the abstract syntax tree datatype shared between GOCC and Miller. I didn't use a `internal/pkg/dsl/ast` naming convention, although that would have been nice, in order to avoid a Go package-dependency cycle.
|
||||
* [internal/pkg/dsl/cst](./internal/pkg/dsl/cst) is the concrete syntax tree, constructed from an AST produced by GOCC. The CST is what is actually executed on every input record when you do things like `$z = $x * 0.3 * $y`. Please see the [internal/pkg/dsl/cst/README.md](./internal/pkg/dsl/cst/README.md) for more information.
|
||||
* The main entry point is [cmd/mlr/main.go](./cmd/mlr/main.go); everything else in [pkg](./pkg).
|
||||
* [pkg/entrypoint](./pkg/entrypoint): All the usual contents of `main()` are here, for ease of testing.
|
||||
* [pkg/platform](./pkg/platform): Platform-dependent code, which as of early 2021 is the command-line parser. Handling single quotes and double quotes is different on Windows unless particular care is taken, which is what this package does.
|
||||
* [pkg/lib](./pkg/lib):
|
||||
* Implementation of the [`Mlrval`](./pkg/types/mlrval.go) datatype which includes string/int/float/boolean/void/absent/error types. These are used for record values, as well as expression/variable values in the Miller `put`/`filter` DSL. See also below for more details.
|
||||
* [`Mlrmap`](./pkg/types/mlrmap.go) is the sequence of key-value pairs which represents a Miller record. The key-lookup mechanism is optimized for Miller read/write usage patterns -- please see [mlrmap.go](./pkg/types/mlrmap.go) for more details.
|
||||
* [`context`](./pkg/types/context.go) supports AWK-like variables such as `FILENAME`, `NF`, `NR`, and so on.
|
||||
* [pkg/cli](./pkg/cli) is the flag-parsing logic for supporting Miller's command-line interface. When you type something like `mlr --icsv --ojson put '$sum = $a + $b' then filter '$sum > 1000' myfile.csv`, it's the CLI parser which makes it possible for Miller to construct a CSV record-reader, a transformer-chain of `put` then `filter`, and a JSON record-writer.
|
||||
* [pkg/climain](./pkg/climain) contains a layer which invokes `pkg/cli`, which was split out to avoid a Go package-import cycle.
|
||||
* [pkg/stream](./pkg/stream) is as above -- it uses Go channels to pipe together file-reads, to record-reading/parsing, to a chain of record-transformers, to record-writing/formatting, to terminal standard output.
|
||||
* [pkg/input](./pkg/input) is as above -- one record-reader type per supported input file format, and a factory method.
|
||||
* [pkg/output](./pkg/output) is as above -- one record-writer type per supported output file format, and a factory method.
|
||||
* [pkg/transformers](./pkg/transformers) contains the abstract record-transformer interface datatype, as well as the Go-channel chaining mechanism for piping one transformer into the next. It also contains all the concrete record-transformers such as `cat`, `tac`, `sort`, `put`, and so on.
|
||||
* [pkg/parsing](./pkg/parsing) contains a single source file, `mlr.bnf`, which is the lexical/semantic grammar file for the Miller `put`/`filter` DSL using the GOCC framework. All subdirectories of `pkg/parsing/` are autogen code created by GOCC's processing of `mlr.bnf`. If you need to edit `mlr.bnf`, please use [tools/build-dsl](./tools/build-dsl) to autogenerate Go code from it (using the GOCC tool). (This takes several minutes to run.)
|
||||
* [pkg/dsl](./pkg/dsl) contains [`ast_types.go`](pkg/dsl/ast_types.go) which is the abstract syntax tree datatype shared between GOCC and Miller. I didn't use a `pkg/dsl/ast` naming convention, although that would have been nice, in order to avoid a Go package-dependency cycle.
|
||||
* [pkg/dsl/cst](./pkg/dsl/cst) is the concrete syntax tree, constructed from an AST produced by GOCC. The CST is what is actually executed on every input record when you do things like `$z = $x * 0.3 * $y`. Please see the [pkg/dsl/cst/README.md](./pkg/dsl/cst/README.md) for more information.
|
||||
|
||||
## Nil-record conventions
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ nil through the reader/transformer/writer sequence.
|
|||
|
||||
## More about mlrvals
|
||||
|
||||
[`Mlrval`](./internal/pkg/types/mlrval.go) is the datatype of record values, as well as expression/variable values in the Miller `put`/`filter` DSL. It includes string/int/float/boolean/void/absent/error types, not unlike PHP's `zval`.
|
||||
[`Mlrval`](./pkg/types/mlrval.go) is the datatype of record values, as well as expression/variable values in the Miller `put`/`filter` DSL. It includes string/int/float/boolean/void/absent/error types, not unlike PHP's `zval`.
|
||||
|
||||
* Miller's `absent` type is like Javascript's `undefined` -- it's for times when there is no such key, as in a DSL expression `$out = $foo` when the input record is `$x=3,y=4` -- there is no `$foo` so `$foo` has `absent` type. Nothing is written to the `$out` field in this case. See also [here](https://miller.readthedocs.io/en/latest/reference-main-null-data) for more information.
|
||||
* Miller's `void` type is like Javascript's `null` -- it's for times when there is a key with no value, as in `$out = $x` when the input record is `$x=,$y=4`. This is an overlap with `string` type, since a void value looks like an empty string. I've gone back and forth on this (including when I was writing the C implementation) -- whether to retain `void` as a distinct type from empty-string, or not. I ended up keeping it as it made the `Mlrval` logic easier to understand.
|
||||
|
|
@ -161,7 +161,7 @@ nil through the reader/transformer/writer sequence.
|
|||
* Miller's number handling makes auto-overflow from int to float transparent, while preserving the possibility of 64-bit bitwise arithmetic.
|
||||
* This is different from JavaScript, which has only double-precision floats and thus no support for 64-bit numbers (note however that there is now [`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)).
|
||||
* This is also different from C and Go, wherein casts are necessary -- without which int arithmetic overflows.
|
||||
* See also [here](https://miller.readthedocs.io/en/latest/reference-main-arithmetic) for the semantics of Miller arithmetic, which the [`Mlrval`](./internal/pkg/types/mlrval.go) class implements.
|
||||
* See also [here](https://miller.readthedocs.io/en/latest/reference-main-arithmetic) for the semantics of Miller arithmetic, which the [`Mlrval`](./pkg/types/mlrval.go) class implements.
|
||||
|
||||
## Performance optimizations
|
||||
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ See also [building from source](https://miller.readthedocs.io/en/latest/build.ht
|
|||
* You can do `./configure --prefix=/some/install/path` before `make install` if you want to install somewhere other than `/usr/local`.
|
||||
* Without `make`:
|
||||
* To build: `go build github.com/johnkerl/miller/cmd/mlr`.
|
||||
* To run tests: `go test github.com/johnkerl/miller/internal/pkg/...` and `mlr regtest`.
|
||||
* To run tests: `go test github.com/johnkerl/miller/pkg/...` and `mlr regtest`.
|
||||
* To install: `go install github.com/johnkerl/miller/cmd/mlr` will install to _GOPATH_`/bin/mlr`.
|
||||
* See also the doc page on [building from source](https://miller.readthedocs.io/en/latest/build).
|
||||
* For more developer information please see [README-dev.md](./README-dev.md).
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/johnkerl/miller/internal/pkg/colorizer"
|
||||
"github.com/johnkerl/miller/pkg/colorizer"
|
||||
)
|
||||
|
||||
const boldString = "\u001b[1m"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/entrypoint"
|
||||
"github.com/johnkerl/miller/pkg/entrypoint"
|
||||
"github.com/pkg/profile" // for trace.out
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/scan"
|
||||
"github.com/johnkerl/miller/pkg/scan"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ nav:
|
|||
- "Auxiliary commands": "reference-main-auxiliary-commands.md"
|
||||
- "Manual page": "manpage.md"
|
||||
- "Building from source": "build.md"
|
||||
- "Miller as a library": "miller-as-library.md"
|
||||
- "How to create a new release": "how-to-release.md"
|
||||
- "Documents for previous releases": "release-docs.md"
|
||||
- "Glossary": "glossary.md"
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ Two-clause BSD license [https://github.com/johnkerl/miller/blob/master/LICENSE.t
|
|||
* `make` creates the `./mlr` (or `.\mlr.exe` on Windows) executable
|
||||
* Without `make`: `go build github.com/johnkerl/miller/cmd/mlr`
|
||||
* `make check` runs tests
|
||||
* Without `make`: `go test github.com/johnkerl/miller/internal/pkg/...` and `mlr regtest`
|
||||
* Without `make`: `go test github.com/johnkerl/miller/pkg/...` and `mlr regtest`
|
||||
* `make install` installs the `mlr` executable and the `mlr` manpage
|
||||
* Without make: `go install github.com/johnkerl/miller/cmd/mlr` will install to _GOPATH_`/bin/mlr`
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ Two-clause BSD license [https://github.com/johnkerl/miller/blob/master/LICENSE.t
|
|||
* `make` creates the `./mlr` (or `.\mlr.exe` on Windows) executable
|
||||
* Without `make`: `go build github.com/johnkerl/miller/cmd/mlr`
|
||||
* `make check` runs tests
|
||||
* Without `make`: `go test github.com/johnkerl/miller/internal/pkg/...` and `mlr regtest`
|
||||
* Without `make`: `go test github.com/johnkerl/miller/pkg/...` and `mlr regtest`
|
||||
* `make install` installs the `mlr` executable and the `mlr` manpage
|
||||
* Without make: `go install github.com/johnkerl/miller/cmd/mlr` will install to _GOPATH_`/bin/mlr`
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ In this example I am using version 6.2.0 to 6.3.0; of course that will change fo
|
|||
|
||||
* Update version found in `mlr --version` and `man mlr`:
|
||||
|
||||
* Edit `internal/pkg/version/version.go` from `6.2.0-dev` to `6.3.0`.
|
||||
* Edit `pkg/version/version.go` from `6.2.0-dev` to `6.3.0`.
|
||||
* Edit `miller.spec`: `Version`, and `changelog` entry
|
||||
* Run `make dev` in the Miller repo base directory
|
||||
* The ordering in this makefile rule is important: the first build creates `mlr`; the second runs `mlr` to create `manpage.txt`; the third includes `manpage.txt` into one of its outputs.
|
||||
|
|
@ -69,6 +69,6 @@ In this example I am using version 6.2.0 to 6.3.0; of course that will change fo
|
|||
|
||||
* Afterwork:
|
||||
|
||||
* Edit `internal/pkg/version/version.go` to change version from `6.3.0` to `6.3.0-dev`.
|
||||
* Edit `pkg/version/version.go` to change version from `6.3.0` to `6.3.0-dev`.
|
||||
* `make dev`
|
||||
* Commit and push.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ In this example I am using version 6.2.0 to 6.3.0; of course that will change fo
|
|||
|
||||
* Update version found in `mlr --version` and `man mlr`:
|
||||
|
||||
* Edit `internal/pkg/version/version.go` from `6.2.0-dev` to `6.3.0`.
|
||||
* Edit `pkg/version/version.go` from `6.2.0-dev` to `6.3.0`.
|
||||
* Edit `miller.spec`: `Version`, and `changelog` entry
|
||||
* Run `make dev` in the Miller repo base directory
|
||||
* The ordering in this makefile rule is important: the first build creates `mlr`; the second runs `mlr` to create `manpage.txt`; the third includes `manpage.txt` into one of its outputs.
|
||||
|
|
@ -53,6 +53,6 @@ In this example I am using version 6.2.0 to 6.3.0; of course that will change fo
|
|||
|
||||
* Afterwork:
|
||||
|
||||
* Edit `internal/pkg/version/version.go` to change version from `6.3.0` to `6.3.0-dev`.
|
||||
* Edit `pkg/version/version.go` to change version from `6.3.0` to `6.3.0-dev`.
|
||||
* `make dev`
|
||||
* Commit and push.
|
||||
|
|
|
|||
|
|
@ -3645,5 +3645,5 @@ MILLER(1) MILLER(1)
|
|||
|
||||
|
||||
|
||||
2023-08-31 MILLER(1)
|
||||
2023-09-10 MILLER(1)
|
||||
</pre>
|
||||
|
|
|
|||
|
|
@ -3624,4 +3624,4 @@ MILLER(1) MILLER(1)
|
|||
|
||||
|
||||
|
||||
2023-08-31 MILLER(1)
|
||||
2023-09-10 MILLER(1)
|
||||
|
|
|
|||
202
docs/src/miller-as-library.md
Normal file
202
docs/src/miller-as-library.md
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
<!--- PLEASE DO NOT EDIT DIRECTLY. EDIT THE .md.in FILE PLEASE. --->
|
||||
<div>
|
||||
<span class="quicklinks">
|
||||
Quick links:
|
||||
|
||||
<a class="quicklink" href="../reference-main-flag-list/index.html">Flags</a>
|
||||
|
||||
<a class="quicklink" href="../reference-verbs/index.html">Verbs</a>
|
||||
|
||||
<a class="quicklink" href="../reference-dsl-builtin-functions/index.html">Functions</a>
|
||||
|
||||
<a class="quicklink" href="../glossary/index.html">Glossary</a>
|
||||
|
||||
<a class="quicklink" href="../release-docs/index.html">Release docs</a>
|
||||
</span>
|
||||
</div>
|
||||
# Miller as a library
|
||||
|
||||
Very initially and experimentally, as of Miller 6.9.1, Go developers will be able to access Miller source
|
||||
code --- moved from `internal/pkg/` to `pkg/` --- within their own Go projects.
|
||||
|
||||
## Setup
|
||||
|
||||
```
|
||||
$ mkdir use-mlr
|
||||
|
||||
$ cd cd use-mlr
|
||||
|
||||
$ go mod init github.com/johnkerl/miller-library-example
|
||||
go: creating new go.mod: module github.com/johnkerl/miller-library-example
|
||||
|
||||
# One of:
|
||||
$ go get github.com/johnkerl/miller
|
||||
$ go get github.com/johnkerl/miller@0f27a39a9f92d4c633dd29d99ad203e95a484dd3
|
||||
# Etc.
|
||||
|
||||
$ go mod tidy
|
||||
```
|
||||
|
||||
## One example use
|
||||
|
||||
<pre class="pre-non-highlight-non-pair">
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/pkg/bifs"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
func main() {
|
||||
a := mlrval.FromInt(2)
|
||||
b := mlrval.FromInt(60)
|
||||
c := bifs.BIF_pow(a, b)
|
||||
fmt.Println(c.String())
|
||||
}
|
||||
</pre>
|
||||
|
||||
```
|
||||
$ go build main1.go
|
||||
$ ./main1
|
||||
1152921504606846976
|
||||
```
|
||||
|
||||
Or simply:
|
||||
```
|
||||
$ go run main1.go
|
||||
1152921504606846976
|
||||
```
|
||||
|
||||
## Another example use
|
||||
|
||||
<pre class="pre-non-highlight-non-pair">
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"container/list"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/johnkerl/miller/pkg/cli"
|
||||
"github.com/johnkerl/miller/pkg/input"
|
||||
"github.com/johnkerl/miller/pkg/output"
|
||||
"github.com/johnkerl/miller/pkg/transformers"
|
||||
"github.com/johnkerl/miller/pkg/types"
|
||||
)
|
||||
|
||||
func convert_csv_to_json(fileNames []string) error {
|
||||
options := &cli.TOptions{
|
||||
ReaderOptions: cli.TReaderOptions{
|
||||
InputFileFormat: "csv",
|
||||
IFS: ",",
|
||||
IRS: "\n",
|
||||
RecordsPerBatch: 1,
|
||||
},
|
||||
WriterOptions: cli.TWriterOptions{
|
||||
OutputFileFormat: "json",
|
||||
},
|
||||
}
|
||||
outputStream := os.Stdout
|
||||
outputIsStdout := true
|
||||
|
||||
// Since Go is concurrent, the context struct needs to be duplicated and
|
||||
// passed through the channels along with each record.
|
||||
initialContext := types.NewContext()
|
||||
|
||||
// Instantiate the record-reader.
|
||||
// RecordsPerBatch is tracked separately from ReaderOptions since join/repl
|
||||
// may use batch size of 1.
|
||||
recordReader, err := input.Create(&options.ReaderOptions, options.ReaderOptions.RecordsPerBatch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Instantiate the record-writer
|
||||
recordWriter, err := output.Create(&options.WriterOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cat, err := transformers.NewTransformerCat(
|
||||
false, // doCounters bool,
|
||||
"", // counterFieldName string,
|
||||
nil, // groupByFieldNames []string,
|
||||
false, // doFileName bool,
|
||||
false, // doFileNum bool,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
recordTransformers := []transformers.IRecordTransformer{cat}
|
||||
|
||||
// Set up the reader-to-transformer and transformer-to-writer channels.
|
||||
readerChannel := make(chan *list.List, 2) // list of *types.RecordAndContext
|
||||
writerChannel := make(chan *list.List, 1) // list of *types.RecordAndContext
|
||||
|
||||
// We're done when a fatal error is registered on input (file not found,
|
||||
// etc) or when the record-writer has written all its output. We use
|
||||
// channels to communicate both of these conditions.
|
||||
inputErrorChannel := make(chan error, 1)
|
||||
doneWritingChannel := make(chan bool, 1)
|
||||
dataProcessingErrorChannel := make(chan bool, 1)
|
||||
|
||||
readerDownstreamDoneChannel := make(chan bool, 1)
|
||||
|
||||
// Start the reader, transformer, and writer. Let them run until fatal input
|
||||
// error or end-of-processing happens.
|
||||
bufferedOutputStream := bufio.NewWriter(outputStream)
|
||||
|
||||
go recordReader.Read(fileNames, *initialContext, readerChannel, inputErrorChannel, readerDownstreamDoneChannel)
|
||||
go transformers.ChainTransformer(readerChannel, readerDownstreamDoneChannel, recordTransformers,
|
||||
writerChannel, options)
|
||||
go output.ChannelWriter(writerChannel, recordWriter, &options.WriterOptions, doneWritingChannel,
|
||||
dataProcessingErrorChannel, bufferedOutputStream, outputIsStdout)
|
||||
|
||||
var retval error
|
||||
done := false
|
||||
for !done {
|
||||
select {
|
||||
case ierr := <-inputErrorChannel:
|
||||
retval = ierr
|
||||
break
|
||||
case _ = <-dataProcessingErrorChannel:
|
||||
retval = errors.New("exiting due to data error") // details already printed
|
||||
break
|
||||
case _ = <-doneWritingChannel:
|
||||
done = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
bufferedOutputStream.Flush()
|
||||
|
||||
return retval
|
||||
}
|
||||
|
||||
func main() {
|
||||
err := convert_csv_to_json(os.Args[1:])
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
|
||||
<pre class="pre-non-highlight-non-pair">
|
||||
host,status
|
||||
apoapsis.east.our.org,up
|
||||
nadir.west.our.org,down
|
||||
</pre>
|
||||
|
||||
```
|
||||
$ go build main2.go
|
||||
$ ./main2 data/hostnames.csv
|
||||
{"host": "apoapsis.east.our.org", "status": "up"}
|
||||
{"host": "nadir.west.our.org", "status": "down"}
|
||||
```
|
||||
|
||||
|
||||
|
||||
54
docs/src/miller-as-library.md.in
Normal file
54
docs/src/miller-as-library.md.in
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# Miller as a library
|
||||
|
||||
Very initially and experimentally, as of Miller 6.9.1, Go developers will be able to access Miller source
|
||||
code --- moved from `internal/pkg/` to `pkg/` --- within their own Go projects.
|
||||
|
||||
## Setup
|
||||
|
||||
```
|
||||
$ mkdir use-mlr
|
||||
|
||||
$ cd cd use-mlr
|
||||
|
||||
$ go mod init github.com/johnkerl/miller-library-example
|
||||
go: creating new go.mod: module github.com/johnkerl/miller-library-example
|
||||
|
||||
# One of:
|
||||
$ go get github.com/johnkerl/miller
|
||||
$ go get github.com/johnkerl/miller@0f27a39a9f92d4c633dd29d99ad203e95a484dd3
|
||||
# Etc.
|
||||
|
||||
$ go mod tidy
|
||||
```
|
||||
|
||||
## One example use
|
||||
|
||||
GENMD-INCLUDE-ESCAPED(miller-as-library/main1.go)
|
||||
|
||||
```
|
||||
$ go build main1.go
|
||||
$ ./main1
|
||||
1152921504606846976
|
||||
```
|
||||
|
||||
Or simply:
|
||||
```
|
||||
$ go run main1.go
|
||||
1152921504606846976
|
||||
```
|
||||
|
||||
## Another example use
|
||||
|
||||
GENMD-INCLUDE-ESCAPED(miller-as-library/main2.go)
|
||||
|
||||
GENMD-INCLUDE-ESCAPED(data/hostnames.csv)
|
||||
|
||||
```
|
||||
$ go build main2.go
|
||||
$ ./main2 data/hostnames.csv
|
||||
{"host": "apoapsis.east.our.org", "status": "up"}
|
||||
{"host": "nadir.west.our.org", "status": "down"}
|
||||
```
|
||||
|
||||
|
||||
|
||||
15
docs/src/miller-as-library/main1.go
Normal file
15
docs/src/miller-as-library/main1.go
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/pkg/bifs"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
func main() {
|
||||
a := mlrval.FromInt(2)
|
||||
b := mlrval.FromInt(60)
|
||||
c := bifs.BIF_pow(a, b)
|
||||
fmt.Println(c.String())
|
||||
}
|
||||
111
docs/src/miller-as-library/main2.go
Normal file
111
docs/src/miller-as-library/main2.go
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"container/list"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/johnkerl/miller/pkg/cli"
|
||||
"github.com/johnkerl/miller/pkg/input"
|
||||
"github.com/johnkerl/miller/pkg/output"
|
||||
"github.com/johnkerl/miller/pkg/transformers"
|
||||
"github.com/johnkerl/miller/pkg/types"
|
||||
)
|
||||
|
||||
func convert_csv_to_json(fileNames []string) error {
|
||||
options := &cli.TOptions{
|
||||
ReaderOptions: cli.TReaderOptions{
|
||||
InputFileFormat: "csv",
|
||||
IFS: ",",
|
||||
IRS: "\n",
|
||||
RecordsPerBatch: 1,
|
||||
},
|
||||
WriterOptions: cli.TWriterOptions{
|
||||
OutputFileFormat: "json",
|
||||
},
|
||||
}
|
||||
outputStream := os.Stdout
|
||||
outputIsStdout := true
|
||||
|
||||
// Since Go is concurrent, the context struct needs to be duplicated and
|
||||
// passed through the channels along with each record.
|
||||
initialContext := types.NewContext()
|
||||
|
||||
// Instantiate the record-reader.
|
||||
// RecordsPerBatch is tracked separately from ReaderOptions since join/repl
|
||||
// may use batch size of 1.
|
||||
recordReader, err := input.Create(&options.ReaderOptions, options.ReaderOptions.RecordsPerBatch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Instantiate the record-writer
|
||||
recordWriter, err := output.Create(&options.WriterOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cat, err := transformers.NewTransformerCat(
|
||||
false, // doCounters bool,
|
||||
"", // counterFieldName string,
|
||||
nil, // groupByFieldNames []string,
|
||||
false, // doFileName bool,
|
||||
false, // doFileNum bool,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
recordTransformers := []transformers.IRecordTransformer{cat}
|
||||
|
||||
// Set up the reader-to-transformer and transformer-to-writer channels.
|
||||
readerChannel := make(chan *list.List, 2) // list of *types.RecordAndContext
|
||||
writerChannel := make(chan *list.List, 1) // list of *types.RecordAndContext
|
||||
|
||||
// We're done when a fatal error is registered on input (file not found,
|
||||
// etc) or when the record-writer has written all its output. We use
|
||||
// channels to communicate both of these conditions.
|
||||
inputErrorChannel := make(chan error, 1)
|
||||
doneWritingChannel := make(chan bool, 1)
|
||||
dataProcessingErrorChannel := make(chan bool, 1)
|
||||
|
||||
readerDownstreamDoneChannel := make(chan bool, 1)
|
||||
|
||||
// Start the reader, transformer, and writer. Let them run until fatal input
|
||||
// error or end-of-processing happens.
|
||||
bufferedOutputStream := bufio.NewWriter(outputStream)
|
||||
|
||||
go recordReader.Read(fileNames, *initialContext, readerChannel, inputErrorChannel, readerDownstreamDoneChannel)
|
||||
go transformers.ChainTransformer(readerChannel, readerDownstreamDoneChannel, recordTransformers,
|
||||
writerChannel, options)
|
||||
go output.ChannelWriter(writerChannel, recordWriter, &options.WriterOptions, doneWritingChannel,
|
||||
dataProcessingErrorChannel, bufferedOutputStream, outputIsStdout)
|
||||
|
||||
var retval error
|
||||
done := false
|
||||
for !done {
|
||||
select {
|
||||
case ierr := <-inputErrorChannel:
|
||||
retval = ierr
|
||||
break
|
||||
case _ = <-dataProcessingErrorChannel:
|
||||
retval = errors.New("exiting due to data error") // details already printed
|
||||
break
|
||||
case _ = <-doneWritingChannel:
|
||||
done = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
bufferedOutputStream.Flush()
|
||||
|
||||
return retval
|
||||
}
|
||||
|
||||
func main() {
|
||||
err := convert_csv_to_json(os.Args[1:])
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
Datatypes for parsing the Miller command line, and the flags table.
|
||||
|
||||
* `internal/pkg/climain` is the flag-parsing logic for supporting Miller's command-line interface. When you type something like `mlr --icsv --ojson put '$sum = $a + $b' then filter '$sum > 1000' myfile.csv`, it's the CLI parser which makes it possible for Miller to construct a CSV record-reader, a transformer chain of `put` then `filter`, and a JSON record-writer.
|
||||
* `internal/pkg/cli` contains datatypes and the flags table for the CLI-parser, which was split out to avoid a Go package-import cycle.
|
||||
|
|
@ -3624,4 +3624,4 @@ MILLER(1) MILLER(1)
|
|||
|
||||
|
||||
|
||||
2023-08-31 MILLER(1)
|
||||
2023-09-10 MILLER(1)
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
.\" Title: mlr
|
||||
.\" Author: [see the "AUTHOR" section]
|
||||
.\" Generator: ./mkman.rb
|
||||
.\" Date: 2023-08-31
|
||||
.\" Date: 2023-09-10
|
||||
.\" Manual: \ \&
|
||||
.\" Source: \ \&
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "MILLER" "1" "2023-08-31" "\ \&" "\ \&"
|
||||
.TH "MILLER" "1" "2023-09-10" "\ \&" "\ \&"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Portability definitions
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
func TestBIF_plus_unary(t *testing.T) {
|
||||
|
|
@ -50,9 +50,9 @@ package bifs
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/types"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/types"
|
||||
)
|
||||
|
||||
// Function-pointer type for zary functions.
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package bifs
|
||||
|
||||
import (
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
func TestBIF_bitcount(t *testing.T) {
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
package bifs
|
||||
|
||||
import (
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
func BIF_logical_NOT(input1 *mlrval.Mlrval) *mlrval.Mlrval {
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
package bifs
|
||||
|
||||
import (
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
@ -5,8 +5,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
func TestBIF_length(t *testing.T) {
|
||||
|
|
@ -5,11 +5,11 @@ import (
|
|||
"regexp"
|
||||
"time"
|
||||
|
||||
strptime "github.com/johnkerl/miller/internal/pkg/pbnjay-strptime"
|
||||
strptime "github.com/johnkerl/miller/pkg/pbnjay-strptime"
|
||||
"github.com/lestrrat-go/strftime"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
const ISO8601_TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
|
||||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"crypto/sha512"
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
func BIF_md5(input1 *mlrval.Mlrval) *mlrval.Mlrval {
|
||||
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
func TestBIF_md5(t *testing.T) {
|
||||
|
|
@ -7,8 +7,8 @@ package bifs
|
|||
import (
|
||||
"math"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -3,7 +3,7 @@ package bifs
|
|||
import (
|
||||
"math"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
func GetPercentileLinearlyInterpolated(
|
||||
|
|
@ -3,8 +3,8 @@ package bifs
|
|||
import (
|
||||
"math"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
func BIF_urand() *mlrval.Mlrval {
|
||||
|
|
@ -3,8 +3,8 @@ package bifs
|
|||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
// BIF_ssub implements the ssub function -- no-frills string-replace, no
|
||||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"math"
|
||||
"strings"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
func BIF_dhms2sec(input1 *mlrval.Mlrval) *mlrval.Mlrval {
|
||||
|
|
@ -4,8 +4,8 @@ import (
|
|||
"math"
|
||||
"sort"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
func stats_test_array(n int) *mlrval.Mlrval {
|
||||
|
|
@ -7,8 +7,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
|
|
@ -6,9 +6,9 @@ import (
|
|||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/platform"
|
||||
"github.com/johnkerl/miller/internal/pkg/version"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/platform"
|
||||
"github.com/johnkerl/miller/pkg/version"
|
||||
)
|
||||
|
||||
func BIF_version() *mlrval.Mlrval {
|
||||
|
|
@ -5,9 +5,9 @@ import (
|
|||
"math"
|
||||
"os"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/types"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
4
pkg/cli/README.md
Normal file
4
pkg/cli/README.md
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Datatypes for parsing the Miller command line, and the flags table.
|
||||
|
||||
* `pkg/climain` is the flag-parsing logic for supporting Miller's command-line interface. When you type something like `mlr --icsv --ojson put '$sum = $a + $b' then filter '$sum > 1000' myfile.csv`, it's the CLI parser which makes it possible for Miller to construct a CSV record-reader, a transformer chain of `put` then `filter`, and a JSON record-writer.
|
||||
* `pkg/cli` contains datatypes and the flags table for the CLI-parser, which was split out to avoid a Go package-import cycle.
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
// o Autogenerating webdocs (mkdocs).
|
||||
//
|
||||
// * For these reasons, flags are organized into tables; for documentation
|
||||
// purposes, flags are organized into sections (see internal/pkg/cli/option_parse.go).
|
||||
// purposes, flags are organized into sections (see pkg/cli/option_parse.go).
|
||||
//
|
||||
// * The Flag struct separates out flag name (e.g. `--csv`), any alternate
|
||||
// names (e.g. `-c`), any arguments the flag may take, a help string, and a
|
||||
|
|
@ -42,8 +42,8 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/colorizer"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/colorizer"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -13,9 +13,9 @@ import (
|
|||
|
||||
"github.com/mattn/go-isatty"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/colorizer"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/colorizer"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
)
|
||||
|
||||
// FinalizeReaderOptions does a few things.
|
||||
|
|
@ -9,7 +9,7 @@ package cli
|
|||
import (
|
||||
"regexp"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
)
|
||||
|
||||
type TCommentHandling int
|
||||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
)
|
||||
|
||||
// For flags with values, e.g. ["-n" "10"], while we're looking at the "-n" this let us see if the "10" slot exists.
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
Logic for parsing the Miller command line.
|
||||
|
||||
* `internal/pkg/climain` is the flag-parsing logic for supporting Miller's command-line interface. When you type something like `mlr --icsv --ojson put '$sum = $a + $b' then filter '$sum > 1000' myfile.csv`, it's the CLI parser which makes it possible for Miller to construct a CSV record-reader, a transformer chain of `put` then `filter`, and a JSON record-writer.
|
||||
* `internal/pkg/cli` contains datatypes for the CLI-parser, which was split out to avoid a Go package-import cycle.
|
||||
* `pkg/climain` is the flag-parsing logic for supporting Miller's command-line interface. When you type something like `mlr --icsv --ojson put '$sum = $a + $b' then filter '$sum > 1000' myfile.csv`, it's the CLI parser which makes it possible for Miller to construct a CSV record-reader, a transformer chain of `put` then `filter`, and a JSON record-writer.
|
||||
* `pkg/cli` contains datatypes for the CLI-parser, which was split out to avoid a Go package-import cycle.
|
||||
* I don't use the Go [`flag`](https://golang.org/pkg/flag/) package. The `flag` package is quite fine; Miller's command-line processing is multi-purpose between serving CLI needs per se as well as for manpage/docfile generation, and I found it simplest to roll my own command-line handling here. More importantly, some Miller verbs such as ``sort`` take flags more than once -- ``mlr sort -f field1 -n field2 -f field3`` -- which is not supported by the `flag` package.
|
||||
|
|
@ -8,7 +8,7 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/cli"
|
||||
"github.com/johnkerl/miller/pkg/cli"
|
||||
)
|
||||
|
||||
// loadMlrrcOrDie rule: If $MLRRC is set, use it and only it. Otherwise try
|
||||
|
|
@ -74,13 +74,13 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/cli"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/terminals"
|
||||
"github.com/johnkerl/miller/internal/pkg/terminals/help"
|
||||
"github.com/johnkerl/miller/internal/pkg/transformers"
|
||||
"github.com/johnkerl/miller/internal/pkg/version"
|
||||
"github.com/johnkerl/miller/pkg/cli"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/terminals"
|
||||
"github.com/johnkerl/miller/pkg/terminals/help"
|
||||
"github.com/johnkerl/miller/pkg/transformers"
|
||||
"github.com/johnkerl/miller/pkg/version"
|
||||
)
|
||||
|
||||
// ParseCommandLine is the entrypoint for handling the Miller command line:
|
||||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
shellquote "github.com/kballard/go-shellquote"
|
||||
)
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
ANSI colors for key/value color highlighting, test pass/fail, etc.
|
||||
|
||||
Not placed in the internal/pkg/platform directory since these don't check the build-for
|
||||
Not placed in the pkg/platform directory since these don't check the build-for
|
||||
platform but rather simply the TERM environment variable.
|
||||
|
|
@ -97,5 +97,5 @@ tree is executed once on every data record.
|
|||
|
||||
# Source directories/files
|
||||
|
||||
* The AST logic is in `./ast*.go`. I didn't use a `internal/pkg/dsl/ast` naming convention, although that would have been nice, in order to avoid a Go package-dependency cycle.
|
||||
* The AST logic is in `./ast*.go`. I didn't use a `pkg/dsl/ast` naming convention, although that would have been nice, in order to avoid a Go package-dependency cycle.
|
||||
* The CST logic is in [`./cst`](./cst). Please see [cst/README.md](./cst/README.md) for more information.
|
||||
|
|
@ -8,8 +8,8 @@ package dsl
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/parsing/token"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/parsing/token"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
package dsl
|
||||
|
||||
import (
|
||||
"github.com/johnkerl/miller/internal/pkg/parsing/token"
|
||||
"github.com/johnkerl/miller/pkg/parsing/token"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -11,7 +11,7 @@ See [../dsl/README.md](../README.md) for more information about Miller's use of
|
|||
|
||||
Go is a strongly typed language, but the AST is polymorphic. This results in if/else or switch statements as an AST is walked.
|
||||
|
||||
Also, when we modify code, there can be changes in the [BNF grammar](../../parsing/mlr.bnf) not yet reflected in the [AST](../../internal/pkg/dsl/ast_types.go). Likewise, there can be AST changes not yet reflected here. (Example: you are partway through adding a new binary operator to the grammar.)
|
||||
Also, when we modify code, there can be changes in the [BNF grammar](../../parsing/mlr.bnf) not yet reflected in the [AST](../../pkg/dsl/ast_types.go). Likewise, there can be AST changes not yet reflected here. (Example: you are partway through adding a new binary operator to the grammar.)
|
||||
|
||||
As a result, throughout the code, there are error checks which may seem redundant but which are in place to make incremental development more pleasant and robust.
|
||||
|
||||
|
|
@ -5,9 +5,9 @@
|
|||
package cst
|
||||
|
||||
import (
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
|
|
@ -8,9 +8,9 @@ package cst
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -6,9 +6,9 @@
|
|||
package cst
|
||||
|
||||
import (
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -19,9 +19,9 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/bifs"
|
||||
"github.com/johnkerl/miller/internal/pkg/colorizer"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/bifs"
|
||||
"github.com/johnkerl/miller/pkg/colorizer"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
)
|
||||
|
||||
type TFunctionClass string
|
||||
|
|
@ -7,11 +7,11 @@ package cst
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/bifs"
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/bifs"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -8,11 +8,11 @@ package cst
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/bifs"
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/bifs"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -8,11 +8,11 @@ package cst
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/parsing/token"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/parsing/token"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
type CondBlockNode struct {
|
||||
|
|
@ -21,11 +21,11 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/output"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/internal/pkg/types"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/output"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
|
|
@ -22,10 +22,10 @@ package cst
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/internal/pkg/types"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/types"
|
||||
)
|
||||
|
||||
type Emit1StatementNode struct {
|
||||
|
|
@ -41,13 +41,13 @@ package cst
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/cli"
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/output"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/internal/pkg/types"
|
||||
"github.com/johnkerl/miller/pkg/cli"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/output"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
|
|
@ -8,12 +8,12 @@ package cst
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/output"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/internal/pkg/types"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/output"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/types"
|
||||
)
|
||||
|
||||
// ================================================================
|
||||
|
|
@ -10,10 +10,10 @@ package cst
|
|||
import (
|
||||
"os"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
type EnvironmentVariableNode struct {
|
||||
|
|
@ -10,10 +10,10 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -19,9 +19,9 @@
|
|||
package cst
|
||||
|
||||
import (
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -7,11 +7,11 @@ package cst
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/parsing/token"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/parsing/token"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -9,8 +9,8 @@
|
|||
package cst
|
||||
|
||||
import (
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -14,12 +14,12 @@ import (
|
|||
|
||||
"github.com/facette/natsort"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
// Most function types are in the github.com/johnkerl/miller/internal/pkg/types package. These types, though,
|
||||
// Most function types are in the github.com/johnkerl/miller/pkg/types package. These types, though,
|
||||
// include functions which need to access CST state in order to call back to
|
||||
// user-defined functions. To avoid a package-cycle dependency, they are
|
||||
// defined here.
|
||||
|
|
@ -7,11 +7,11 @@ package cst
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/parsing/token"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/parsing/token"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/colorizer"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/colorizer"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -8,10 +8,10 @@ import (
|
|||
"fmt"
|
||||
"math"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -9,10 +9,10 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -9,11 +9,11 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/output"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/internal/pkg/types"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/output"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/types"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -11,13 +11,13 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/cli"
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/output"
|
||||
"github.com/johnkerl/miller/internal/pkg/parsing/lexer"
|
||||
"github.com/johnkerl/miller/internal/pkg/parsing/parser"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/cli"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/output"
|
||||
"github.com/johnkerl/miller/pkg/parsing/lexer"
|
||||
"github.com/johnkerl/miller/pkg/parsing/parser"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
)
|
||||
|
||||
// NewEmptyRoot sets up an empty CST, before ingesting any DSL strings. For
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
package cst
|
||||
|
||||
import (
|
||||
"github.com/johnkerl/miller/internal/pkg/types"
|
||||
"github.com/johnkerl/miller/pkg/types"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -8,7 +8,7 @@ package cst
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -9,8 +9,8 @@
|
|||
package cst
|
||||
|
||||
import (
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
@ -7,12 +7,12 @@ package cst
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/johnkerl/miller/internal/pkg/dsl"
|
||||
"github.com/johnkerl/miller/internal/pkg/lib"
|
||||
"github.com/johnkerl/miller/internal/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/internal/pkg/output"
|
||||
"github.com/johnkerl/miller/internal/pkg/runtime"
|
||||
"github.com/johnkerl/miller/internal/pkg/types"
|
||||
"github.com/johnkerl/miller/pkg/dsl"
|
||||
"github.com/johnkerl/miller/pkg/lib"
|
||||
"github.com/johnkerl/miller/pkg/mlrval"
|
||||
"github.com/johnkerl/miller/pkg/output"
|
||||
"github.com/johnkerl/miller/pkg/runtime"
|
||||
"github.com/johnkerl/miller/pkg/types"
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue