@barmark/cli 0.5.1 → 0.6.1

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/CHANGELOG.md CHANGED
@@ -6,6 +6,31 @@ package uses [semantic versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.6.1] - 2026-11-07
10
+
11
+ ### Changed
12
+
13
+ - **Uses** barmark 0.17.0, @barmark/render 0.15.0 and @barmark/musicxml
14
+ 0.6.0: voice parts and lyrics. `check` and `format` read syllables on
15
+ notes and lyric rows, `render` draws them, `export --musicxml` writes
16
+ `<lyric>` verses and `import` brings melodies and verses back.
17
+
18
+ ## [0.6.0] - 2026-11-06
19
+
20
+ ### Added
21
+
22
+ - **`barmark import <file>`** reads a MusicXML score (`.musicxml`, `.xml`
23
+ or compressed `.mxl`; UTF-8 or UTF-16), as a chart: to stdout, or to
24
+ `--out`; `--part <name>` (a part's name, abbreviation or id, ignoring
25
+ case and punctuation) imports one part alone, its notes as note sets.
26
+ What the chart can't carry over goes to stderr as `file: measure N
27
+ (Part): severity: message`, as `check` prints its findings, the measure
28
+ left out when the diagnostic lists its measures (the message is never
29
+ searched). Exits 0 when a chart came out, even with warnings, and
30
+ 1 when none did or the `.mxl` is bad. The standalone binary includes it.
31
+ - **Uses** @barmark/musicxml 0.5.0 (with barmark 0.16.0 and
32
+ @barmark/render 0.14.0).
33
+
9
34
  ## [0.5.1] - 2026-11-05
10
35
 
11
36
  ### Fixed
@@ -163,7 +188,9 @@ The first release of the `barmark` command. Uses `barmark` 0.8.0 and
163
188
  - **The `barmark` command:** `check`, `format`, `render` and `transpose`
164
189
  for `.chart.md` files, on npm and as standalone binaries.
165
190
 
166
- [Unreleased]: https://github.com/kevinpeckham/barmark/compare/cli-v0.5.1...HEAD
191
+ [Unreleased]: https://github.com/kevinpeckham/barmark/compare/cli-v0.6.1...HEAD
192
+ [0.6.1]: https://github.com/kevinpeckham/barmark/compare/cli-v0.6.0...cli-v0.6.1
193
+ [0.6.0]: https://github.com/kevinpeckham/barmark/compare/cli-v0.5.1...cli-v0.6.0
167
194
  [0.5.1]: https://github.com/kevinpeckham/barmark/compare/cli-v0.5.0...cli-v0.5.1
168
195
  [0.5.0]: https://github.com/kevinpeckham/barmark/compare/cli-v0.4.0...cli-v0.5.0
169
196
  [0.4.0]: https://github.com/kevinpeckham/barmark/compare/cli-v0.3.0...cli-v0.4.0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @barmark/cli
2
2
 
3
- The `barmark` command: check, format, part, render, transpose and export
3
+ The `barmark` command: check, format, part, render, transpose, export and import
4
4
  [Barmark](https://www.barmark.dev) chord charts (`.chart.md` files) in a
5
5
  terminal or in CI. It runs the same `barmark` parser and `@barmark/render`
6
6
  renderer as barmark.dev, and `@barmark/musicxml` for MusicXML, at exact
@@ -34,6 +34,7 @@ dot-folders and symlinks. `-` reads from stdin.
34
34
  ```sh
35
35
  barmark check songs # errors and warnings, file:line
36
36
  barmark export --musicxml song.chart.md --out song.musicxml # for MuseScore, Dorico…
37
+ barmark import song.musicxml --out song.chart.md # or a compressed song.mxl
37
38
  barmark check --strict --format github songs # warnings fail too; PR annotations
38
39
  barmark format song.chart.md # print it in standard form
39
40
  barmark format --write songs # rewrite the files that change
@@ -55,6 +56,16 @@ libraries.
55
56
  play in the chart's order; `--part <label>` exports one part. A chart
56
57
  with errors is not exported. A chart with no title takes its file name.
57
58
 
59
+ `import` reads a MusicXML score (`.musicxml`, `.xml` or compressed `.mxl`)
60
+ as a chart. What the chart can't carry over is listed on stderr, one line
61
+ each, as `check` prints its findings: `song.mxl: measure 12 (Piano):
62
+ warning: message` (the measure left out when the message lists the
63
+ measures itself). `--part <name>` (a
64
+ part's name, abbreviation or id, ignoring case and punctuation) imports
65
+ one part alone, its notes as note sets. It exits 0 when a chart came out,
66
+ even with warnings, and 1 when none did or the `.mxl` is bad. It does not
67
+ read stdin.
68
+
58
69
  ## Exit codes
59
70
 
60
71
  | Code | Meaning |
package/dist/help.js CHANGED
@@ -5,6 +5,7 @@ Commands:
5
5
  check <paths…> Report each chart's errors and warnings
6
6
  export <file> Write a chart as MusicXML (--musicxml)
7
7
  format <paths…> Print or rewrite charts in standard form
8
+ import <file> Read a MusicXML score as a chart
8
9
  part <label> <file> Print one part of a chart of several
9
10
  render <file> Write a chart as a standalone HTML page
10
11
  transpose <file> Print a chart in another key
@@ -59,6 +60,16 @@ A standalone HTML page of the chart, with the Edwin font embedded.
59
60
  --part <label> Draw only this part
60
61
  --diagnostics List the chart's problems below it
61
62
  --font-url <url> Link the font instead of embedding it
63
+ `,
64
+ import: `Usage: barmark import <file> [options]
65
+
66
+ A MusicXML score (.musicxml, .xml or compressed .mxl; from MuseScore, Dorico, Sibelius, Finale…) as a chart.
67
+ Chord symbols become chords; what the chart can't carry over goes to
68
+ stderr as file: measure N (Part): message. Exits 0 when a chart came out,
69
+ even with warnings; 1 when none did or the .mxl is bad. Does not read stdin.
70
+
71
+ --out <file> Write to a file instead of stdout
72
+ --part <name> Import one part alone, its notes as note sets
62
73
  `,
63
74
  part: `Usage: barmark part <label> <file> [options]
64
75
 
package/dist/import.js ADDED
@@ -0,0 +1,54 @@
1
+ /** barmark import: a MusicXML score (.musicxml, .xml or .mxl) as a chart. */
2
+ import { decodeXmlBytes, importMusicXml, readMxl } from "@barmark/musicxml";
3
+ import { parseFlags } from "./args.js";
4
+ import { readBytes } from "./inputs.js";
5
+ import { UsageError } from "./io.js";
6
+ import { writeOutput } from "./output.js";
7
+ /** Control characters shown as U+FFFD: nothing from a file reaches the terminal as an escape sequence. */
8
+ const printable = (text) => text.replace(/\p{Cc}/gu, "\uFFFD");
9
+ /**
10
+ * `file: measure N (Part): severity: message`, as `check` prints its
11
+ * `file:line: severity: message`; each piece of the place left out when the
12
+ * diagnostic has none, or when the message names its measures itself.
13
+ */
14
+ export function importLine(path, d) {
15
+ const where = [
16
+ // A diagnostic with `measures` names them in its message; the message is never searched.
17
+ d.measure === undefined || d.measures !== undefined ? "" : `measure ${d.measure}`,
18
+ d.part === undefined ? "" : `(${d.part})`,
19
+ ].filter(Boolean);
20
+ const place = where.length ? `${where.join(" ")}: ` : "";
21
+ return printable(`${path}: ${place}${d.severity}: ${d.message}`);
22
+ }
23
+ /** The score's XML text: a .mxl is unpacked. Rejects with a message naming the problem. */
24
+ async function scoreText(bytes, path) {
25
+ return /\.mxl$/i.test(path) ? readMxl(bytes) : decodeXmlBytes(bytes);
26
+ }
27
+ export async function importCommand(args, io) {
28
+ const { values, positionals } = parseFlags(args, {
29
+ out: { type: "string" },
30
+ part: { type: "string" },
31
+ });
32
+ const [path, ...rest] = positionals;
33
+ if (path === undefined)
34
+ throw new UsageError("no file given");
35
+ if (rest.length)
36
+ throw new UsageError("import takes one file");
37
+ const bytes = readBytes(path, io);
38
+ let xml;
39
+ try {
40
+ xml = await scoreText(bytes, path);
41
+ }
42
+ catch (error) {
43
+ io.stderr(`${printable(`${path}: ${error instanceof Error ? error.message : String(error)}`)}\n`);
44
+ return 1;
45
+ }
46
+ const result = importMusicXml(xml, values.part === undefined ? {} : { part: values.part });
47
+ for (const d of result.diagnostics)
48
+ io.stderr(`${importLine(path, d)}\n`);
49
+ // As export does: no file written from an import that gave nothing.
50
+ if (result.text === "")
51
+ return 1;
52
+ writeOutput(result.text, values.out, io);
53
+ return 0;
54
+ }
package/dist/inputs.js CHANGED
@@ -45,6 +45,16 @@ function readText(full, shown) {
45
45
  throw new UsageError(`cannot read ${shown}`);
46
46
  }
47
47
  }
48
+ /** A file's raw bytes, with the same complaints as a chart that can't be read. */
49
+ export function readBytes(path, io) {
50
+ const [full] = filesFor(path, io, false);
51
+ try {
52
+ return readFileSync(full);
53
+ }
54
+ catch {
55
+ throw new UsageError(`cannot read ${path}`);
56
+ }
57
+ }
48
58
  export async function readCharts(paths, io, opts) {
49
59
  if (!paths.length)
50
60
  throw new UsageError("no chart given");
package/dist/main.js CHANGED
@@ -3,6 +3,7 @@ import { check } from "./check.js";
3
3
  import { exportCommand } from "./export.js";
4
4
  import { format } from "./format.js";
5
5
  import { COMMAND_HELP, HELP } from "./help.js";
6
+ import { importCommand } from "./import.js";
6
7
  import { UsageError } from "./io.js";
7
8
  import { part } from "./part.js";
8
9
  import { render } from "./render.js";
@@ -12,6 +13,7 @@ export const COMMANDS = {
12
13
  check,
13
14
  export: exportCommand,
14
15
  format,
16
+ import: importCommand,
15
17
  part,
16
18
  render,
17
19
  transpose,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barmark/cli",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
4
  "description": "The barmark command: check, format, render, transpose and export barmark chord charts (.chart.md) from the terminal and in CI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -37,9 +37,9 @@
37
37
  "url": "https://github.com/kevinpeckham/barmark/issues"
38
38
  },
39
39
  "dependencies": {
40
- "barmark": "0.16.0",
41
- "@barmark/render": "0.14.0",
42
- "@barmark/musicxml": "0.4.1"
40
+ "barmark": "0.17.0",
41
+ "@barmark/render": "0.15.0",
42
+ "@barmark/musicxml": "0.6.0"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "rm -rf dist && tsc -p tsconfig.build.json",