Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

移行: フラグ CLI からサブコマンド CLI へ

This page is for users of the old flag-style CLI (one process, many mutually exclusive --action flags) who are moving to the subcommand CLI (bca <verb>). It maps every old invocation to its replacement. The mapping table is the quick reference; the side-by-side examples show each in context.

変更の理由

The flag CLI overloaded --output-format with two unrelated meanings: per-file serialization (-O json/yaml/toml/cbor) and a post-walk aggregated report (-O markdown). It needed two clap ArgGroups plus runtime checks to police invalid combinations, and --top / --strip-prefix lived as global flags that only applied to one format. Each further aggregated format (HTML, for example) would have compounded the fragility.

サブコマンド CLI はこの構造を修正します。bca metrics と bca ops はファイルごとの出力を、bca report <FORMAT> は集約レポートを出力し、各動詞は自分専用にスコープされたフラグ集合を持ちます。

移行対応表

旧新
--metrics -O markdown (+ --top, --strip-prefix)report markdown
--metrics -O json/yaml/toml/cbormetrics -O json/yaml/toml/cbor
--metrics -O checkstyle/sarif/code-climate/clang-warning/msvc-warningcheck --threshold ... --report-format <fmt> [--output FILE]
--ops -O ...ops -O ...
--dumpdump
--find <NODE>find -t <NODE> [-t <NODE>...]
--count <LIST>count -t <NODE> [-t <NODE>...]
--functionfunctions
--comments [--in-place]strip-comments [--in-place]
--preproc <FILE> <FILE>...(生成側)preproc -o <OUT>
--preproc <FILE>(消費側)--preproc-data <FILE>(サブコマンドごと、動詞の後に指定)
--list-metrics [MODE]list-metrics [MODE]
--pr(pretty 表示)--pretty(metrics と ops で使用)
--ls, --le(グローバル)dump/find の --line-start、--line-end(--ls/--le は非推奨のエイリアスとして残存)
-p, -I, -X, -j, -lサブコマンドにスコープされます。動詞の 後に 渡してください(-w は引き続き全体共通)

新旧対照の例

集約 Markdown レポート

# 旧
big-code-analysis-cli \
    --metrics \
    --paths "$PWD" \
    --output-format markdown \
    --jobs $(nproc) \
    --top 20 \
    --strip-prefix "$PWD/"

# 新
bca \
    report \
    --paths "$PWD" \
    --format markdown \
    --top 20 \
    --strip-prefix "$PWD/"

ファイル単位のメトリクス抽出

# 旧
big-code-analysis-cli --metrics --paths ./src --output-format json --output ./out/

# 新(ファイル単位ツリー: --output は 2.0 で --output-dir になりました)
bca metrics --paths ./src -O json --output-dir ./out/

ファイル単位の ops 抽出

# 旧: big-code-analysis-cli --ops --paths ./src -O json -o ./out/
# 新: bca ops --paths ./src -O json --output-dir ./out/

AST ダンプ

# 旧: big-code-analysis-cli --dump --paths ./file.rs
# 新: bca dump --paths ./file.rs

ノードの検索 / カウント

# 旧: big-code-analysis-cli --find call_expression --paths ./src
# 新: bca find --paths ./src -t call_expression

# 旧: big-code-analysis-cli --count if_statement,for_statement --paths ./src
# 新: bca count --paths ./src -t if_statement -t for_statement

Note: find and count now take one node type per -t / --type flag (repeat it for several) rather than a positional or a comma-separated string; the positional slot holds input paths.

関数のスパン

# 旧: big-code-analysis-cli --function --paths ./src
# 新: bca functions --paths ./src

コメントの除去

# 旧: big-code-analysis-cli --comments --in-place --paths ./src
# 新: bca strip-comments --paths ./src --in-place

Preproc data: producer

# 旧
big-code-analysis-cli --metrics --preproc a.h --preproc b.h \
    --paths ./src -o /tmp/p.json

# 新
bca preproc --paths ./src -o /tmp/p.json

Preproc data: consumer

# 旧
big-code-analysis-cli --metrics --preproc /tmp/p.json \
    --paths ./src -O json -o ./out/

# 新
bca metrics --paths ./src --preproc-data /tmp/p.json \
    -O json --output-dir ./out/

メトリクス一覧

# 旧: big-code-analysis-cli --list-metrics descriptions
# 新: bca list-metrics descriptions

実行時の移行ヒント

If you run a legacy invocation, the CLI prints a hint naming the recognized old flags and their new equivalents before clap’s own error:

$ bca --metrics -O markdown
note: the CLI was restructured into subcommands. See the migration guide for the full mapping:
  https://dekobon.github.io/big-code-analysis/migration.html
  --metrics  ->  bca metrics
  -O markdown  ->  bca report markdown|html [--top N] [--strip-prefix P]
  Run `bca --help` for the new command list.

error: unexpected argument '--metrics' found