@barmark/cli 0.1.8 → 0.2.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,29 @@ package uses [semantic versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.1] - 2026-11-04
10
+
11
+ ### Changed
12
+
13
+ - **Uses** barmark 0.14.1, @barmark/render 0.12.0 and @barmark/musicxml
14
+ 0.1.1: `export --musicxml` writes slashes one per beat, and prints a
15
+ repeat count above 2 as "×N", so both read correctly in Dorico.
16
+
17
+ ## [0.2.0] - 2026-11-04
18
+
19
+ ### Added
20
+
21
+ - **`barmark export --musicxml <file>`:** the chart as MusicXML 4.0,
22
+ through `@barmark/musicxml`, with `--out` and `--part <label>`. A chart
23
+ with errors is not exported; a chart with no title takes its file name,
24
+ less the extension.
25
+ - **`--version`** names `@barmark/musicxml` too.
26
+
27
+ ### Changed
28
+
29
+ - **Uses** barmark 0.14.1, @barmark/render 0.12.0 and @barmark/musicxml
30
+ 0.1.0.
31
+
9
32
  ## [0.1.8] - 2026-11-03
10
33
 
11
34
  Uses `barmark` 0.14.1 and `@barmark/render` 0.12.0, pinned exactly: fixes
@@ -85,7 +108,9 @@ The first release of the `barmark` command. Uses `barmark` 0.8.0 and
85
108
  - **The `barmark` command:** `check`, `format`, `render` and `transpose`
86
109
  for `.chart.md` files, on npm and as standalone binaries.
87
110
 
88
- [Unreleased]: https://github.com/kevinpeckham/barmark/compare/cli-v0.1.8...HEAD
111
+ [Unreleased]: https://github.com/kevinpeckham/barmark/compare/cli-v0.2.1...HEAD
112
+ [0.2.1]: https://github.com/kevinpeckham/barmark/compare/cli-v0.2.0...cli-v0.2.1
113
+ [0.2.0]: https://github.com/kevinpeckham/barmark/compare/cli-v0.1.8...cli-v0.2.0
89
114
  [0.1.8]: https://github.com/kevinpeckham/barmark/compare/cli-v0.1.7...cli-v0.1.8
90
115
  [0.1.7]: https://github.com/kevinpeckham/barmark/compare/cli-v0.1.6...cli-v0.1.7
91
116
  [0.1.6]: https://github.com/kevinpeckham/barmark/compare/cli-v0.1.5...cli-v0.1.6
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @barmark/cli
2
2
 
3
- The `barmark` command: check, format, part, render and transpose
3
+ The `barmark` command: check, format, part, render, transpose and export
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
- renderer as barmark.dev, at exact versions, so a chart means the same
7
- thing everywhere.
6
+ renderer as barmark.dev, and `@barmark/musicxml` for MusicXML, at exact
7
+ versions, so a chart means the same thing everywhere.
8
8
 
9
9
  ## Install
10
10
 
@@ -33,6 +33,7 @@ dot-folders and symlinks. `-` reads from stdin.
33
33
 
34
34
  ```sh
35
35
  barmark check songs # errors and warnings, file:line
36
+ barmark export --musicxml song.chart.md --out song.musicxml # for MuseScore, Dorico…
36
37
  barmark check --strict --format github songs # warnings fail too; PR annotations
37
38
  barmark format song.chart.md # print it in standard form
38
39
  barmark format --write songs # rewrite the files that change
@@ -47,9 +48,13 @@ takes the renderer's options as flags: `--theme auto|light|dark`,
47
48
  `--numerals nashville|roman`, `--no-bar-numbers`, `--rehearsal-letters`,
48
49
  `--no-wrap`, `--diagnostics`, `--part <label>` to draw one part, and `--font-url <url>` to link the font
49
50
  instead of embedding it. `barmark <command> --help` lists each command's
50
- flags; `barmark --version` prints the versions of the CLI and both
51
+ flags; `barmark --version` prints the versions of the CLI and its
51
52
  libraries.
52
53
 
54
+ `export --musicxml` writes MusicXML 4.0 that notation programs open and
55
+ play in the chart's order; `--part <label>` exports one part. A chart
56
+ with errors is not exported. A chart with no title takes its file name.
57
+
53
58
  ## Exit codes
54
59
 
55
60
  | Code | Meaning |
package/dist/export.js ADDED
@@ -0,0 +1,30 @@
1
+ /** barmark export: a chart in another format; MusicXML for now. */
2
+ import { basename } from "node:path";
3
+ import { exportMusicXml } from "@barmark/musicxml";
4
+ import { parseFlags } from "./args.js";
5
+ import { readCharts, STDIN } from "./inputs.js";
6
+ import { UsageError } from "./io.js";
7
+ import { onlyChart, writeOutput } from "./output.js";
8
+ import { textLine } from "./report.js";
9
+ export async function exportCommand(args, io) {
10
+ const { values, positionals } = parseFlags(args, {
11
+ musicxml: { type: "boolean" },
12
+ out: { type: "string" },
13
+ part: { type: "string" },
14
+ });
15
+ if (!values.musicxml)
16
+ throw new UsageError("give a format: --musicxml");
17
+ const { path, text } = onlyChart(await readCharts(positionals, io, { folders: false }), "export");
18
+ const result = exportMusicXml(text, {
19
+ ...(values.part === undefined ? {} : { part: values.part }),
20
+ ...(path === STDIN ? {} : { title: basename(path).replace(/(\.chart)?\.[^.]*$/, "") }),
21
+ });
22
+ // As transpose does: problems to stderr, and no file written from a chart with errors.
23
+ for (const d of result.diagnostics)
24
+ io.stderr(`${d.line ? textLine(path, d) : `${path}: ${d.message}`}\n`);
25
+ if (result.ok)
26
+ writeOutput(result.xml, values.out, io);
27
+ else if (values.out !== undefined)
28
+ io.stderr(`${values.out} not written: the chart has errors\n`);
29
+ return result.ok ? 0 : 1;
30
+ }
package/dist/help.js CHANGED
@@ -3,6 +3,7 @@ export const HELP = `Usage: barmark <command> [options]
3
3
 
4
4
  Commands:
5
5
  check <paths…> Report each chart's errors and warnings
6
+ export <file> Write a chart as MusicXML (--musicxml)
6
7
  format <paths…> Print or rewrite charts in standard form
7
8
  part <label> <file> Print one part of a chart of several
8
9
  render <file> Write a chart as a standalone HTML page
@@ -26,6 +27,16 @@ inside them; - reads stdin.
26
27
  text: path:line: severity: message (default)
27
28
  github: annotations on a pull request
28
29
  json: an array of { file, diagnostics }
30
+ `,
31
+ export: `Usage: barmark export --musicxml <file> [options]
32
+
33
+ The chart as MusicXML 4.0, for MuseScore, Dorico, Sibelius or Finale: one
34
+ part per declared part, playing in the chart's order. A chart with errors
35
+ is not exported; problems go to stderr.
36
+
37
+ --musicxml Export MusicXML (the one format for now)
38
+ --out <file> Write to a file instead of stdout
39
+ --part <label> Export only this part
29
40
  `,
30
41
  format: `Usage: barmark format <paths…> [options]
31
42
 
package/dist/inputs.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { readdirSync, readFileSync, statSync } from "node:fs";
3
3
  import { join, relative, resolve } from "node:path";
4
4
  import { UsageError } from "./io.js";
5
- const STDIN = "<stdin>";
5
+ export const STDIN = "<stdin>";
6
6
  /**
7
7
  * Every `*.chart.md` under a folder, sorted, skipping node_modules and dot-folders.
8
8
  * Symlinks are skipped too, so `format --write` never rewrites a file outside the folder.
package/dist/main.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /** The barmark command: dispatch to a subcommand, and turn every failure into one line and an exit code. */
2
2
  import { check } from "./check.js";
3
+ import { exportCommand } from "./export.js";
3
4
  import { format } from "./format.js";
4
5
  import { COMMAND_HELP, HELP } from "./help.js";
5
6
  import { UsageError } from "./io.js";
@@ -7,12 +8,19 @@ import { part } from "./part.js";
7
8
  import { render } from "./render.js";
8
9
  import { transpose } from "./transpose.js";
9
10
  /** Each subcommand by name. */
10
- export const COMMANDS = { check, format, part, render, transpose };
11
+ export const COMMANDS = {
12
+ check,
13
+ export: exportCommand,
14
+ format,
15
+ part,
16
+ render,
17
+ transpose,
18
+ };
11
19
  export async function main(argv, io) {
12
20
  const [name, ...args] = argv;
13
21
  if (name === "--version" || name === "-v") {
14
- const { cli, barmark, render } = io.versions;
15
- io.stdout(`@barmark/cli ${cli} (barmark ${barmark}, @barmark/render ${render})\n`);
22
+ const { cli, barmark, render, musicxml } = io.versions;
23
+ io.stdout(`@barmark/cli ${cli} (barmark ${barmark}, @barmark/render ${render}, @barmark/musicxml ${musicxml})\n`);
16
24
  return 0;
17
25
  }
18
26
  if (name === "--help" || name === "-h") {
package/dist/node-io.js CHANGED
@@ -8,7 +8,12 @@ function versionAt(entry) {
8
8
  }
9
9
  function versions() {
10
10
  const own = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
11
- return { cli: own.version, barmark: versionAt("barmark"), render: versionAt("@barmark/render") };
11
+ return {
12
+ cli: own.version,
13
+ barmark: versionAt("barmark"),
14
+ render: versionAt("@barmark/render"),
15
+ musicxml: versionAt("@barmark/musicxml"),
16
+ };
12
17
  }
13
18
  async function readStdin() {
14
19
  const chunks = [];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@barmark/cli",
3
- "version": "0.1.8",
4
- "description": "The barmark command: check, format, render and transpose barmark chord charts (.chart.md) from the terminal and in CI.",
3
+ "version": "0.2.1",
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": {
7
7
  "barmark": "./dist/cli.js"
@@ -38,7 +38,8 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "barmark": "0.14.1",
41
- "@barmark/render": "0.12.0"
41
+ "@barmark/render": "0.12.0",
42
+ "@barmark/musicxml": "0.1.1"
42
43
  },
43
44
  "scripts": {
44
45
  "build": "rm -rf dist && tsc -p tsconfig.build.json",