Add support for the new parameter of Terrain50.ParseStream()

This commit is contained in:
Starbeamrainbowlabs 2020-07-16 17:07:25 +01:00
parent f7c59bfa90
commit 3c99fd4a4c
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
3 changed files with 11 additions and 2 deletions

View File

@ -14,6 +14,9 @@ npm install --save terrain50-cli
-----
## Unreleased
- Add new `--use-regex` flag to `validate` subcommand
## v1.3
- Added new `identify` subcommand
- Added new `stream-slice` subcommand

View File

@ -16,8 +16,8 @@ export default async function(settings) {
break;
case "stream":
let i = 0;
for await (let next of Terrain50.ParseStream(process.stdin)) {
let i = 0
for await (let next of Terrain50.ParseStream(process.stdin, settings.cli.use_regex ? /\s+/ : " ")) {
console.log(`>>> Item ${i} <<<`);
display_errors(next.validate());
i++;

View File

@ -5,3 +5,9 @@ name = "mode"
description = "The mode to operate in. Possible values: validate (default), stream. If stream, then validation will be done on individual items after parsing (otherwise validation is done during parsing, which catches more errors)"
default_value = "validate"
type = "string"
[[arguments]]
name = "use-regex"
description = "When in stream mode, setting this flag causes a regular expression to be used when parsing input data (otherwise it is assumed a single space separates data elements on a line). Makes the parser more tolerant, but less performant."
default_value = false
type = "boolean"