From 3c99fd4a4c2f707b70b80e73570773e36462bd52 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 16 Jul 2020 17:07:25 +0100 Subject: [PATCH] Add support for the new parameter of Terrain50.ParseStream() --- Changelog.md | 3 +++ src/Subcommands/validate/index.mjs | 4 ++-- src/Subcommands/validate/meta.toml | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 93fc915..c0e00c2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/src/Subcommands/validate/index.mjs b/src/Subcommands/validate/index.mjs index 6634570..67005e0 100644 --- a/src/Subcommands/validate/index.mjs +++ b/src/Subcommands/validate/index.mjs @@ -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++; diff --git a/src/Subcommands/validate/meta.toml b/src/Subcommands/validate/meta.toml index a85f6d9..a6d6f43 100644 --- a/src/Subcommands/validate/meta.toml +++ b/src/Subcommands/validate/meta.toml @@ -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"