@barmark/cli 0.13.0 → 0.14.0

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.14.0] - 2026-11-19
10
+
11
+ ### Added
12
+
13
+ - **`export --lyricsheet`** writes the chart as a ChordPro lyric sheet
14
+ (usually `.cho`), to stdout or `--out`; `--part <label>` writes one
15
+ part's chords, and `--diagrams guitar` adds guitar chord diagrams. What
16
+ the sheet can't carry goes to stderr as `song.chart.md: warning:
17
+ message`, each message naming its own bars. `--version` lists
18
+ `@barmark/lyricsheet`.
19
+
20
+ ### Changed
21
+
22
+ - **`check`, `format`, `render` and the exports read more spellings of
23
+ the major seventh** (`CMaj9`, `Cma13`, `CmΔ7`, `C∆7`, `Cm△9`), as
24
+ `barmark` now reads them; they print canonically.
25
+ - **`render --score`: a lyric row's rhythm slashes sit on their line**,
26
+ with no ledger lines through them.
27
+ - **Uses** barmark 0.25.0, @barmark/render 0.20.2, @barmark/musicxml
28
+ 0.9.3, @barmark/score 0.6.3, @barmark/midi 0.3.5 and
29
+ @barmark/lyricsheet 0.1.0 (and through them @barmark/fretboard 0.1.2
30
+ and @barmark/sync 0.4.3).
31
+
9
32
  ## [0.13.0] - 2026-11-14
10
33
 
11
34
  ### Changed
@@ -411,7 +434,8 @@ The first release of the `barmark` command. Uses `barmark` 0.8.0 and
411
434
  - **The `barmark` command:** `check`, `format`, `render` and `transpose`
412
435
  for `.chart.md` files, on npm and as standalone binaries.
413
436
 
414
- [Unreleased]: https://github.com/kevinpeckham/barmark/compare/cli-v0.13.0...HEAD
437
+ [Unreleased]: https://github.com/kevinpeckham/barmark/compare/cli-v0.14.0...HEAD
438
+ [0.14.0]: https://github.com/kevinpeckham/barmark/compare/cli-v0.13.0...cli-v0.14.0
415
439
  [0.13.0]: https://github.com/kevinpeckham/barmark/compare/cli-v0.12.0...cli-v0.13.0
416
440
  [0.12.0]: https://github.com/kevinpeckham/barmark/compare/cli-v0.11.3...cli-v0.12.0
417
441
  [0.11.3]: https://github.com/kevinpeckham/barmark/compare/cli-v0.11.2...cli-v0.11.3
package/README.md CHANGED
@@ -38,6 +38,7 @@ barmark export --musicxml song.chart.md --out song.musicxml # for MuseScore, D
38
38
  barmark import song.musicxml --out song.chart.md # or a compressed song.mxl
39
39
  barmark export --midi song.chart.md --out song.mid # for a DAW or a practice player
40
40
  barmark import song.mid --out song.chart.md # chords named from the notes
41
+ barmark export --lyricsheet song.chart.md --out song.cho # a ChordPro lyric sheet
41
42
  barmark check --strict --format github songs # warnings fail too; PR annotations
42
43
  barmark format song.chart.md # print it in standard form
43
44
  barmark format --write songs # rewrite the files that change
@@ -108,6 +109,25 @@ names the harmony's tracks by number or name (ignoring case) instead of
108
109
  letting the import choose. As for MusicXML, it exits 1 when no chart came
109
110
  out.
110
111
 
112
+ `export --lyricsheet` writes the chart as a ChordPro lyric sheet, text for
113
+ any app that reads ChordPro (the usual extension is `.cho`), to stdout or
114
+ `--out`. `--part <label>` writes one part's chords with the singer's
115
+ words, and `--diagrams guitar` adds guitar chord diagrams. A chart with no
116
+ title takes its file name. What a lyric sheet can't hold goes to stderr as
117
+ `song.chart.md: warning: message`, each message naming its own bars. A
118
+ chart with errors is not exported.
119
+
120
+ ```sh
121
+ $ barmark export --lyricsheet examples/shenandoah.chart.md
122
+ {title: Shenandoah}
123
+ {key: C}
124
+ {time: 4/4}
125
+ {comment: A simplified arrangement of the traditional song, every note a quarter.}
126
+
127
+ {start_of_verse: label="Verse"}
128
+ [*N.C.]Oh [C]Shenandoah [C]I long to hear [F]you
129
+ ```
130
+
111
131
  ## Exit codes
112
132
 
113
133
  | Code | Meaning |
package/dist/export.js CHANGED
@@ -1,11 +1,13 @@
1
- /** barmark export: a chart in another format: MusicXML, or a MIDI file. */
1
+ /** barmark export: a chart in another format: MusicXML, a MIDI file or a lyric sheet. */
2
2
  import { basename } from "node:path";
3
+ import { exportLyricsheet } from "@barmark/lyricsheet";
3
4
  import { exportMidi } from "@barmark/midi";
4
5
  import { exportMusicXml } from "@barmark/musicxml";
5
- import { parseFlags } from "./args.js";
6
+ import { oneOf, parseFlags } from "./args.js";
6
7
  import { readCharts, STDIN } from "./inputs.js";
7
8
  import { UsageError } from "./io.js";
8
9
  import { onlyChart, writeFile, writeOutput } from "./output.js";
10
+ import { DIAGRAMS } from "./render.js";
9
11
  import { textLine } from "./report.js";
10
12
  /**
11
13
  * `file: bar N: warning: message`, as `check` prints its findings; N is the
@@ -19,31 +21,35 @@ export function lossLine(path, loss) {
19
21
  const diagnosticLine = (path, d) => d.line ? textLine(path, d) : `${path}: ${d.message}`;
20
22
  /** The format the flags name: exactly one; --midi writes bytes, so it needs --out. */
21
23
  function formatOf(values) {
22
- if (values.musicxml && values.midi)
23
- throw new UsageError("give one format: --musicxml or --midi");
24
- if (values.midi) {
25
- if (values.out === undefined)
26
- throw new UsageError("--midi writes a file: give --out <file.mid>");
27
- return "midi";
28
- }
29
- if (values.musicxml)
30
- return "musicxml";
31
- throw new UsageError("give a format: --musicxml or --midi");
24
+ const named = ["musicxml", "midi", "lyricsheet"].filter((f) => values[f]);
25
+ if (named.length > 1)
26
+ throw new UsageError("give one format: --musicxml, --midi or --lyricsheet");
27
+ const format = named[0];
28
+ if (format === undefined)
29
+ throw new UsageError("give a format: --musicxml, --midi or --lyricsheet");
30
+ if (format === "midi" && values.out === undefined)
31
+ throw new UsageError("--midi writes a file: give --out <file.mid>");
32
+ if (values.diagrams !== undefined && format !== "lyricsheet")
33
+ throw new UsageError("--diagrams goes with --lyricsheet");
34
+ return format;
32
35
  }
33
36
  export async function exportCommand(args, io) {
34
37
  const { values, positionals } = parseFlags(args, {
35
38
  musicxml: { type: "boolean" },
36
39
  midi: { type: "boolean" },
40
+ lyricsheet: { type: "boolean" },
37
41
  out: { type: "string" },
38
42
  part: { type: "string" },
43
+ diagrams: { type: "string" },
39
44
  });
40
45
  const format = formatOf(values);
46
+ const diagrams = values.diagrams === undefined ? undefined : oneOf("diagrams", values.diagrams, DIAGRAMS);
41
47
  const { path, text } = onlyChart(await readCharts(positionals, io, { folders: false }), "export");
42
48
  const options = {
43
49
  ...(values.part === undefined ? {} : { part: values.part }),
44
50
  ...(path === STDIN ? {} : { title: basename(path).replace(/(\.chart)?\.[^.]*$/, "") }),
45
51
  };
46
- const result = format === "midi" ? exportMidi(text, options) : exportMusicXml(text, options);
52
+ const result = convert(format, text, options, diagrams);
47
53
  // As transpose does: problems to stderr, and no file written from a chart with errors.
48
54
  for (const d of result.diagnostics)
49
55
  io.stderr(`${diagnosticLine(path, d)}\n`);
@@ -52,13 +58,30 @@ export async function exportCommand(args, io) {
52
58
  io.stderr(`${values.out} not written: the chart has errors\n`);
53
59
  return 1;
54
60
  }
61
+ writeResult(result, path, values.out, io);
62
+ return 0;
63
+ }
64
+ function convert(format, text, options, diagrams) {
65
+ if (format === "midi")
66
+ return exportMidi(text, options);
67
+ if (format === "lyricsheet")
68
+ return exportLyricsheet(text, { ...options, ...(diagrams ? { diagrams } : {}) });
69
+ return exportMusicXml(text, options);
70
+ }
71
+ /** A good result's losses to stderr, then its file or its text. */
72
+ function writeResult(result, path, out, io) {
55
73
  if ("bytes" in result) {
56
74
  for (const loss of result.losses)
57
75
  io.stderr(`${lossLine(path, loss)}\n`);
58
76
  // formatOf made --out required for --midi.
59
- writeFile(values.out, result.bytes, io);
77
+ writeFile(out, result.bytes, io);
78
+ }
79
+ else if ("text" in result) {
80
+ // The sheet's messages name their bars already: no second naming.
81
+ for (const loss of result.losses)
82
+ io.stderr(`${lossLine(path, { message: loss.message })}\n`);
83
+ writeOutput(result.text, out, io);
60
84
  }
61
85
  else
62
- writeOutput(result.xml, values.out, io);
63
- return 0;
86
+ writeOutput(result.xml, out, io);
64
87
  }
package/dist/help.js CHANGED
@@ -3,7 +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 or MIDI (--musicxml, --midi)
6
+ export <file> Write a chart as MusicXML, MIDI or a lyric sheet (--musicxml, --midi, --lyricsheet)
7
7
  format <paths…> Print or rewrite charts in standard form
8
8
  import <file> Read a MusicXML score or a MIDI file as a chart
9
9
  part <label> <file> Print one part of a chart of several
@@ -29,18 +29,22 @@ inside them; - reads stdin.
29
29
  github: annotations on a pull request
30
30
  json: an array of { file, diagnostics }
31
31
  `,
32
- export: `Usage: barmark export (--musicxml | --midi) <file> [options]
32
+ export: `Usage: barmark export (--musicxml | --midi | --lyricsheet) <file> [options]
33
33
 
34
34
  The chart as MusicXML 4.0, for MuseScore, Dorico, Sibelius or Finale: one
35
35
  part per declared part, playing in the chart's order. Or as a MIDI file
36
36
  of its play order, for a DAW or a practice player; what MIDI can't hold
37
- goes to stderr as file: bar N: warning: message. A chart with errors is
38
- not exported; problems go to stderr.
37
+ goes to stderr as file: bar N: warning: message. Or as a lyric sheet, a
38
+ text file in ChordPro's format (usually .cho) for any app that reads
39
+ it; what it can't hold goes to stderr as file: warning: message. A chart
40
+ with errors is not exported; problems go to stderr.
39
41
 
40
42
  --musicxml Export MusicXML
41
43
  --midi Export a Standard MIDI File (needs --out)
42
44
  --out <file> Write to a file instead of stdout
45
+ --lyricsheet Export a ChordPro lyric sheet
43
46
  --part <label> Export only this part
47
+ --diagrams guitar With --lyricsheet: add guitar chord diagrams
44
48
  `,
45
49
  format: `Usage: barmark format <paths…> [options]
46
50
 
package/dist/main.js CHANGED
@@ -21,8 +21,8 @@ export const COMMANDS = {
21
21
  export async function main(argv, io) {
22
22
  const [name, ...args] = argv;
23
23
  if (name === "--version" || name === "-v") {
24
- const { cli, barmark, render, musicxml, score, midi, verovio } = io.versions;
25
- io.stdout(`@barmark/cli ${cli} (barmark ${barmark}, @barmark/render ${render}, @barmark/musicxml ${musicxml}, @barmark/score ${score}, @barmark/midi ${midi}, verovio ${verovio})\n`);
24
+ const { cli, barmark, render, musicxml, score, midi, lyricsheet, verovio } = io.versions;
25
+ io.stdout(`@barmark/cli ${cli} (barmark ${barmark}, @barmark/render ${render}, @barmark/musicxml ${musicxml}, @barmark/score ${score}, @barmark/midi ${midi}, @barmark/lyricsheet ${lyricsheet}, verovio ${verovio})\n`);
26
26
  return 0;
27
27
  }
28
28
  if (name === "--help" || name === "-h") {
package/dist/node-io.js CHANGED
@@ -15,6 +15,7 @@ function versions() {
15
15
  musicxml: versionAt("@barmark/musicxml"),
16
16
  score: versionAt("@barmark/score"),
17
17
  midi: versionAt("@barmark/midi"),
18
+ lyricsheet: versionAt("@barmark/lyricsheet"),
18
19
  verovio: versionAt("verovio"),
19
20
  };
20
21
  }
package/dist/render.js CHANGED
@@ -13,7 +13,7 @@ import { DEFAULT_WIDTH, MAX_WIDTH, MIN_WIDTH, scoreBody } from "./score.js";
13
13
  const THEMES = ["auto", "light", "dark"];
14
14
  const NUMERALS = ["nashville", "roman"];
15
15
  const COLUMNS = ["shared", "row"];
16
- const DIAGRAMS = ["guitar"];
16
+ export const DIAGRAMS = ["guitar"];
17
17
  const escapeHtml = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
18
18
  function htmlDocument(title, body) {
19
19
  return `<!doctype html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barmark/cli",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
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,11 +37,12 @@
37
37
  "url": "https://github.com/kevinpeckham/barmark/issues"
38
38
  },
39
39
  "dependencies": {
40
- "barmark": "0.24.0",
41
- "@barmark/render": "0.20.1",
42
- "@barmark/musicxml": "0.9.2",
43
- "@barmark/midi": "0.3.4",
44
- "@barmark/score": "0.6.1",
40
+ "barmark": "0.25.0",
41
+ "@barmark/render": "0.20.2",
42
+ "@barmark/musicxml": "0.9.3",
43
+ "@barmark/midi": "0.3.5",
44
+ "@barmark/lyricsheet": "0.1.0",
45
+ "@barmark/score": "0.6.3",
45
46
  "verovio": "6.4.1"
46
47
  },
47
48
  "scripts": {