@bablr/cli 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,13 +10,13 @@ This package has no built-in language support, but rather expects you to supply
10
10
  Usage: bablr [options]
11
11
 
12
12
  Options:
13
- -l, --language [URL] The URL of the BABLR language to parse with
14
- -p, --production [type] The top-level type for the parse
15
- -f, --format Pretty-format CSTML output
13
+ -l, --language [URL] The URL of the top BABLR language
14
+ -p, --production [type] The name of the top production type
16
15
  -F, --no-format Produce machine-readable CSTML output
16
+ -f, --format Pretty-format CSTML output (default: true)
17
17
  -v, --verbose Prints debugging information to stderr
18
- -c, --color Force colored output (default: true)
19
- -C, --no-color Do not color output
18
+ -c, --color [WHEN] When to use ANSI escape colors
19
+ WHEN: auto | always | never (default: "auto")
20
20
  -e, --embedded Requires quoted input but enables gap parsing
21
21
  -h, --help display help for command
22
22
  ```
package/bin/index.js CHANGED
@@ -15,18 +15,31 @@ import { generateCSTML } from '../lib/syntax.js';
15
15
  import { writeLinesToWritableStream } from '../lib/utils/node.js';
16
16
 
17
17
  program
18
- .option('-l, --language [URL]', 'The URL of the BABLR language to parse with')
19
- .option('-p, --production [type]', 'The top-level type for the parse')
18
+ .option('-l, --language [URL]', 'The URL of the top BABLR language')
19
+ .option('-p, --production [type]', 'The name of the top production type')
20
20
  .option('-F, --no-format', 'Produce machine-readable CSTML output')
21
- .option('-f, --format', 'Pretty-format CSTML output')
21
+ .option('-f, --format', 'Pretty-format CSTML output', true)
22
22
  .option('-v, --verbose', 'Prints debugging information to stderr')
23
- .option('-c, --color', 'Force colored output', true)
24
- .option('-C, --no-color', 'Do not color output')
23
+ .option(
24
+ '-c, --color [WHEN]',
25
+ 'When to use ANSI escape colors. \n WHEN: auto | always | never',
26
+ 'auto',
27
+ )
25
28
  .option('-e, --embedded', 'Requires quoted input but enables gap parsing')
26
29
  .parse(process.argv);
27
30
 
28
31
  const programOpts = program.opts();
29
- const options = { ...programOpts, color: colorSupport.hasBasic && programOpts.color };
32
+
33
+ if (programOpts.color && !['auto', 'always', 'never'].includes(programOpts.color.toLowerCase())) {
34
+ throw new Error('invalid value for --color');
35
+ }
36
+
37
+ const options = {
38
+ ...programOpts,
39
+ color:
40
+ (programOpts.color.toLowerCase() === 'auto' && colorSupport.hasBasic) ||
41
+ programOpts.color.toLowerCase() === 'always',
42
+ };
30
43
 
31
44
  const language = await import(options.language);
32
45
 
package/lib/syntax.js CHANGED
@@ -38,13 +38,9 @@ function* __higlightStrategy(tokens) {
38
38
  (token.value.type === 'String' && currentRef.name === 'intrinsicValue')
39
39
  ) {
40
40
  yield i`push(bold green)`;
41
- } else if (token.value.type === 'String') {
42
- yield i`push(bold white)`;
43
41
  } else if (token.value.type === 'Identifier') {
44
- if (currentType === 'Punctuator' && currentRef.name === 'type') {
45
- yield i`push(whiteBright bold)`;
46
- } else if (currentType === 'Reference') {
47
- yield i`push(gray)`;
42
+ if (currentType === 'Reference') {
43
+ yield i`push(bold gray)`;
48
44
  } else {
49
45
  yield i`push()`;
50
46
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bablr/cli",
3
3
  "description": "CLI for running BABLR parsers",
4
- "version": "0.1.7",
4
+ "version": "0.1.9",
5
5
  "author": "Conrad Buck<conartist6@gmail.com>",
6
6
  "type": "module",
7
7
  "files": [