@barmark/cli

中文文档
0.6.5发布于 2026/11/08MITES Module构建来源已验证近 30 天下载 3588

The barmark command: check, format, render, transpose and export barmark chord charts (.chart.md) from the terminal and in CI.

原始使用文档
文档目录5 节
  1. Install
  2. Commands
  3. Exit codes
  4. In CI
  5. License

@barmark/cli

The barmark command: check, format, part, render, transpose, export and import Barmark chord charts (.chart.md files) in a terminal or in CI. It runs the same barmark parser and @barmark/render renderer as barmark.dev, and @barmark/musicxml for MusicXML, at exact versions, so a chart means the same thing everywhere.

Install

With Node 20.6 or later:

npx @barmark/cli check .          # run once
npm install --save-dev @barmark/cli   # or keep it in a project

Without Node, download the binary for your system from the GitHub release (barmark-linux-x64, barmark-linux-arm64, barmark-darwin-x64, barmark-darwin-arm64, barmark-windows-x64.exe). The binaries are not signed yet; on macOS, clear the download flag before the first run:

chmod +x barmark-darwin-arm64
xattr -d com.apple.quarantine barmark-darwin-arm64

Commands

Folders mean every *.chart.md file inside them, skipping node_modules, dot-folders and symlinks. - reads from stdin.

barmark check songs                      # errors and warnings, file:line
barmark export --musicxml song.chart.md --out song.musicxml   # for MuseScore, Dorico…
barmark import song.musicxml --out song.chart.md   # or a compressed song.mxl
barmark check --strict --format github songs   # warnings fail too; PR annotations
barmark format song.chart.md             # print it in standard form
barmark format --write songs             # rewrite the files that change
barmark format --check songs             # list them and fail, for CI
barmark part Bass song.chart.md          # one part of a chart of several
barmark render song.chart.md --out song.html   # a standalone page, font included
barmark transpose song.chart.md --to E   # or --semitones -2

check --format json prints the diagnostics for other tools. render takes the renderer's options as flags: --theme auto|light|dark, --numerals nashville|roman, --no-bar-numbers, --rehearsal-letters, --no-wrap, --diagnostics, --part <label> to draw one part, and --font-url <url> to link the font instead of embedding it. barmark <command> --help lists each command's flags; barmark --version prints the versions of the CLI and its libraries.

export --musicxml writes MusicXML 4.0 that notation programs open and play in the chart's order; --part <label> exports one part. A chart with errors is not exported. A chart with no title takes its file name.

import reads a MusicXML score (.musicxml, .xml or compressed .mxl) as a chart. What the chart can't carry over is listed on stderr, one line each, as check prints its findings: song.mxl: measure 12 (Piano): warning: message (the measure left out when the message lists the measures itself). --part <name> (a part's name, abbreviation or id, ignoring case and punctuation) imports one part alone, its notes as note sets. It exits 0 when a chart came out, even with warnings, and 1 when none did or the .mxl is bad. It does not read stdin.

Exit codes

CodeMeaning
0Done (warnings are allowed unless --strict)
1The charts have problems: an error, a warning with --strict, or a file format --check would change
2The command was used wrongly: an unknown flag, a missing or unreadable file

In CI

- uses: actions/setup-node@v4
  with:
    node-version: 22
- run: npx -y @barmark/[email protected] check --strict --format github songs
- run: npx -y @barmark/[email protected] format --check songs

Pin the version: a new release can read a chart differently, and a pinned version turns that into a pull request you review.

License

MIT. render embeds Edwin, which @barmark/render ships under the SIL Open Font License (fonts/OFL.txt there; the binaries' release carries it as Edwin-OFL.txt).

版本与发布记录

@barmark/cli 共发布 24 个版本,首次发布于 2026/11/03;过去 12 个月发布了 24 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.6.5latest2026/11/08今天
0.6.42026/11/08今天
0.6.32026/11/08今天
0.6.22026/11/07今天
0.6.12026/11/07今天
0.6.02026/11/061 天前

关于 @barmark/cli 的常见问题

@barmark/cli 是什么?

The barmark command: check, format, render, transpose and export barmark chord charts (.chart.md) from the terminal and in CI.

如何安装 @barmark/cli?

在项目目录运行 npm install @barmark/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 barmark,可以用 npx barmark 直接运行。

@barmark/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/barmark__cli 是否存在。

@barmark/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@barmark/cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.6。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@barmark/cli 可以商用吗?

@barmark/cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@barmark/cli 的下载量有多少?

根据 npm 官方下载统计,@barmark/cli 在 2026/10/08 – 2026/11/06 这 30 天内被下载 3,588 次,日均约 120 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@barmark/cli 还在维护吗?

最新版本 0.6.5 发布于 2026/11/08(今天);至今共发布 24 个版本,其中过去 12 个月发布了 24 个;首次发布于 2026/11/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。