Skip to content

Docs and CLI Improvements - #471

Merged
leonardehrenfried merged 2 commits into
mainfrom
docs-and-cli
Jul 6, 2026
Merged

Docs and CLI Improvements#471
leonardehrenfried merged 2 commits into
mainfrom
docs-and-cli

Conversation

@aaronbrethorst

@aaronbrethorst aaronbrethorst commented Jul 4, 2026

Copy link
Copy Markdown
Member

Summary:

  • Corrects and updates and the docs for the merge and transform CLI tools
  • Exposes --duplicateRenaming option to merge CLI
  • Adds tests for new CLI behavior

Summary by CodeRabbit

  • New Features

    • Added a new duplicate-renaming option for GTFS merges, with per-input-file behavior and support for different renaming modes.
    • Updated the transformer CLI so inputs come before the output path, with clearer support for files, archives, and inline or file-based transform specs.
  • Documentation

    • Refreshed CLI docs to match current command usage, option ordering, and merge behavior.
    • Updated runtime requirements to Java 25+.
  • Tests

    • Added coverage for duplicate-renaming behavior and option pairing across multiple inputs.

The prose in docs/ and the transformer usage.txt did not accurately
describe the actual CLI behavior.

Rewrite them from the GtfsMergerMain / GtfsTransformerMain source:

- merge: drop the non-existent --fuzzyDuplicates / --renameDuplicates flags;
  document reverse-order precedence, automatic id-prefix renaming, per-file
  index-pairing of --duplicateDetection, --debug, and the --file requirement
  for the log/error flags. Reworked the service-change example accordingly.
- transformer: list the full flag set (--modifications alias, --reference,
  built-in transform flags, file-parameter flags) and note command-line order.
- bump documented Java runtime to 25 to match the build target.
EDuplicateRenamingStrategy.AGENCY (prefix colliding ids with "<agency_id>-"
instead of the context-based "a-", "b-", ...) has been settable via the Java
API since 2015 and is exercised by GtfsMergerTest's Puget Sound tests, but no
CLI ever exposed it. The Puget Sound consolidated bundle depends on it, so
reproducing that bundle from the command line was impossible.

The new option is index-paired with --file, matching --duplicateDetection:

  --file=stops.txt --duplicateDetection=none --duplicateRenaming=agency

This commit also contains end-to-end coverage of the new option. Two feeds
with colliding stop and trip ids are merged and the output feed is read back.

- agency renaming prefixes the lower-priority feed's colliding stop with
  "<agency_id>-" ("3-100")
- omitting the option preserves the historical context prefix ("a-100")
- values are index-paired with --file, so stops and trips can use different
  renaming strategies in one invocation

This is the merge-cli module's first test, so the pom gains a test-scoped
junit-jupiter-api dependency (version managed by the parent).
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a --duplicateRenaming CLI option (context|agency) to the GTFS merge tool, applied per input file index in GtfsMergerMain, with new unit tests and a test dependency addition. Rewrites documentation for both the merge and transformer CLIs, including usage.txt, reflecting Java 25+ requirement and updated argument semantics.

Changes

Merge CLI duplicate renaming feature

Layer / File(s) Summary
--duplicateRenaming option implementation
onebusaway-gtfs-merge-cli/src/main/java/org/onebusaway/gtfs_merge/GtfsMergerMain.java, onebusaway-gtfs-merge-cli/pom.xml
Adds EDuplicateRenamingStrategy import, a duplicateRenamingOptions field bound to --duplicateRenaming, per-file-index application logic in buildMerger(), and a test-scoped junit-jupiter-api dependency.
Duplicate renaming tests
onebusaway-gtfs-merge-cli/src/test/java/org/onebusaway/gtfs_merge/GtfsMergerMainTest.java
Adds a new test class with mock colliding feeds and tests for agency-based renaming, default context renaming, and paired --file/--duplicateRenaming options, plus CLI-run, merge-read, and lookup helper methods.
Merge CLI documentation rewrite
docs/onebusaway-gtfs-merge-cli.md
Rewrites introduction, Java 25+ requirement, invocation syntax, feed-combination order, per-file --duplicateDetection configuration, duplicate handling/logging behavior, other options, and the example.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Transformer CLI documentation updates

Layer / File(s) Summary
Transformer CLI docs and usage.txt updates
docs/onebusaway-gtfs-transformer-cli.md, onebusaway-gtfs-transformer-cli/src/main/resources/org/onebusaway/gtfs_transformer/usage.txt
Updates Java requirement to 25+, expands the Arguments section with positional output path and option-order semantics, and restructures usage.txt into core args, built-in transform flags, and file-parameter flags sections.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is broadly related to the change but too generic to convey the main doc and CLI updates. Use a more specific title such as "Update GTFS CLI docs and add duplicate renaming support".
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs-and-cli

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/onebusaway-gtfs-merge-cli.md`:
- Line 23: Add a language identifier to each fenced code block in the markdown
so markdownlint MD040 passes. Update the fences in the docs content around the
onebusaway-gtfs-merge-cli examples to use a shell language tag consistently for
the blocks at the referenced locations, keeping the existing command text
unchanged.
- Around line 34-42: The merge CLI docs currently describe only the default
context-prefix renaming and the per-`--file` pairing logic, but they never
mention the new `--duplicateRenaming` option introduced by
`GtfsMergerMain.buildMerger()`. Update this section to document
`--duplicateRenaming` alongside `--duplicateDetection`, explain that it is
supplied per input index via `--file`-indexed options, and list the supported
values (`context` and `agency`) so users can discover how to switch from the
default context-based renaming to agency-based renaming.
- Around line 56-66: The recognized GTFS files list is missing support for
areas, even though GtfsMergerMain already accepts Area through
AreaMergeStrategy. Update the documented supported-files section to include
areas.txt alongside the other recognized inputs, keeping the list aligned with
the merger’s actual capabilities and the Area-related symbols used in the CLI.

In `@onebusaway-gtfs-merge-cli/pom.xml`:
- Around line 29-33: The test dependency setup in pom.xml only adds
junit-jupiter-api, so GtfsMergerMainTest still won’t execute because the JUnit 5
engine is missing. Update the test dependencies in this module to include
junit-jupiter-engine, or replace the current JUnit 5 API dependency with the
junit-jupiter aggregate, while keeping the existing parent-managed versioning
intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 18448845-dbde-422f-b473-33907259b7e3

📥 Commits

Reviewing files that changed from the base of the PR and between 39f169d and f9cd94d.

📒 Files selected for processing (6)
  • docs/onebusaway-gtfs-merge-cli.md
  • docs/onebusaway-gtfs-transformer-cli.md
  • onebusaway-gtfs-merge-cli/pom.xml
  • onebusaway-gtfs-merge-cli/src/main/java/org/onebusaway/gtfs_merge/GtfsMergerMain.java
  • onebusaway-gtfs-merge-cli/src/test/java/org/onebusaway/gtfs_merge/GtfsMergerMainTest.java
  • onebusaway-gtfs-transformer-cli/src/main/resources/org/onebusaway/gtfs_transformer/usage.txt


To run the application:

```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add a language identifier to fenced code blocks.

markdownlint flags these three blocks (MD040) for missing a language.

📝 Proposed fix
-```
+```shell
 java -jar onebusaway-gtfs-merge-cli.jar [options] input_gtfs_path_a input_gtfs_path_b ... output_gtfs_path

Apply the same fix at lines 49 and 125.

Also applies to: 49-49, 125-125

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 23-23: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/onebusaway-gtfs-merge-cli.md` at line 23, Add a language identifier to
each fenced code block in the markdown so markdownlint MD040 passes. Update the
fences in the docs content around the onebusaway-gtfs-merge-cli examples to use
a shell language tag consistently for the blocks at the referenced locations,
keeping the existing command text unchanged.

Source: Linters/SAST tools

Comment on lines +34 to +42
### How feeds are combined

Input feeds are processed in **reverse command-line order** — entities from the *last* feed listed are
added to the output first, and entities from earlier feeds are merged in afterward. When an entity
from an earlier feed collides with one already in the output and is *not* treated as a duplicate (see
below), its id is automatically renamed by prefixing it (e.g. `a-`, `b-`, …), and all references to it
are rewritten. This automatic renaming replaces the old `--renameDuplicates` flag, which no longer
exists.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Missing documentation for the new --duplicateRenaming option.

This section documents the automatic context-prefix renaming and the --file/--duplicateDetection per-index pairing, but never mentions --duplicateRenaming at all — the very option this PR introduces to let users pick agency-based renaming instead of the default context prefix. GtfsMergerMain.buildMerger() pairs duplicateRenamingOptions by index exactly like duplicateDetectionOptions (same --file-indexed pattern), so readers have no way to discover this flag or its context/agency values from the docs.

📝 Suggested addition
 Input feeds are processed in **reverse command-line order** — entities from the *last* feed listed are
 added to the output first, and entities from earlier feeds are merged in afterward. When an entity
 from an earlier feed collides with one already in the output and is *not* treated as a duplicate (see
 below), its id is automatically renamed by prefixing it (e.g. `a-`, `b-`, …), and all references to it
 are rewritten. This automatic renaming replaces the old `--renameDuplicates` flag, which no longer
 exists.
+
+By default, colliding ids are renamed using the context prefix above. You can instead rename them
+using the owning agency's id with `--duplicateRenaming=agency`, paired by position with `--file` just
+like `--duplicateDetection` (see below). `--duplicateRenaming=context` restores the default explicitly.
+Values are case-insensitive.

As per the PR objectives, "It exposes the --duplicateRenaming option in the merge CLI, allowing agency-based duplicate renaming to be selected from the command line," so the docs rewrite should cover it.

Also applies to: 43-70

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/onebusaway-gtfs-merge-cli.md` around lines 34 - 42, The merge CLI docs
currently describe only the default context-prefix renaming and the per-`--file`
pairing logic, but they never mention the new `--duplicateRenaming` option
introduced by `GtfsMergerMain.buildMerger()`. Update this section to document
`--duplicateRenaming` alongside `--duplicateDetection`, explain that it is
supplied per input index via `--file`-indexed options, and list the supported
values (`context` and `agency`) so users can discover how to switch from the
default context-based renaming to agency-based renaming.

Comment on lines 56 to +66
- `agency.txt`
- `stops.txt`
- `routes.txt`
- `trips.txt` and `stop_times.txt`
- `calendar.txt` and `calendar_dates.txt`
- `calendar.txt` and `calendar_dates.txt`
- `shapes.txt`
- `fare_attributes.txt`
- `fare_rules.txt`
- `frequencies.txt`
- `transfers.txt`

You can specify merge options for each of these files using the `--file=gtfs_file.txt` option. File types listed
together (eg. `trips.txt` and `stop_times.txt`) are handled by the same merge strategy, so specifying options for
either will have the same effect. For details on options you might specify, read on.
- `fare_attributes.txt`
- `fare_rules.txt`
- `feed_info.txt`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find all CsvFields filename declarations to compare against the documented list
rg -n 'filename\s*=\s*"' --type java -g '!**/test/**'

Repository: OneBusAway/onebusaway-gtfs-modules

Length of output: 172


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate likely GTFS merger/doc sources and map their structure.
git ls-files | rg '(^|/)(docs/onebusaway-gtfs-merge-cli\.md|.*GtfsMerger.*|.*GtfsEntitySchemaFactory.*|.*entityClassesByFilename.*|.*MergeStrategy.*)$'

printf '\n## Outline: docs/onebusaway-gtfs-merge-cli.md\n'
wc -l docs/onebusaway-gtfs-merge-cli.md
sed -n '1,220p' docs/onebusaway-gtfs-merge-cli.md

printf '\n## Search: filenames / recognized files / merge strategies\n'
rg -n 'entityClassesByFilename|getEntityClasses|Recognized files|merge strategy|MergeStrategy|filename' src test . -g '!**/target/**' -g '!**/build/**'

Repository: OneBusAway/onebusaway-gtfs-modules

Length of output: 45058


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# If the search above was too broad, narrow down by likely package names.
fd -a 'GtfsMergerMain.*|GtfsMerger.*|GtfsEntitySchemaFactory.*' .

Repository: OneBusAway/onebusaway-gtfs-modules

Length of output: 812


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '## GtfsEntitySchemaFactory\n'
sed -n '1,220p' onebusaway-gtfs/src/main/java/org/onebusaway/gtfs/serialization/GtfsEntitySchemaFactory.java

printf '\n## GtfsMergerMain\n'
sed -n '1,260p' onebusaway-gtfs-merge-cli/src/main/java/org/onebusaway/gtfs_merge/GtfsMergerMain.java

printf '\n## GtfsMerger\n'
sed -n '1,320p' onebusaway-gtfs-merge/src/main/java/org/onebusaway/gtfs_merge/GtfsMerger.java

Repository: OneBusAway/onebusaway-gtfs-modules

Length of output: 20324


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '## GtfsEntitySchemaFactoryTest\n'
sed -n '1,220p' onebusaway-gtfs/src/test/java/org/onebusaway/gtfs/serialization/GtfsEntitySchemaFactoryTest.java

printf '\n## GtfsMergerMainTest\n'
sed -n '1,260p' onebusaway-gtfs-merge-cli/src/test/java/org/onebusaway/gtfs_merge/GtfsMergerMainTest.java

printf '\n## GtfsMergerTest relevant strategy assertions\n'
sed -n '250,380p' onebusaway-gtfs-merge/src/test/java/org/onebusaway/gtfs_merge/GtfsMergerTest.java

Repository: OneBusAway/onebusaway-gtfs-modules

Length of output: 13058


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '## Merge strategy entity-type mappings\n'
rg -n 'getEntityTypes|new .*MergeStrategy|extends Abstract' onebusaway-gtfs-merge/src/main/java/org/onebusaway/gtfs_merge/strategies -g '!**/target/**'

printf '\n## TripMergeStrategy\n'
sed -n '1,220p' onebusaway-gtfs-merge/src/main/java/org/onebusaway/gtfs_merge/strategies/TripMergeStrategy.java

printf '\n## ServiceCalendarMergeStrategy\n'
sed -n '1,220p' onebusaway-gtfs-merge/src/main/java/org/onebusaway/gtfs_merge/strategies/ServiceCalendarMergeStrategy.java

printf '\n## AreaMergeStrategy\n'
sed -n '1,160p' onebusaway-gtfs-merge/src/main/java/org/onebusaway/gtfs_merge/strategies/AreaMergeStrategy.java

Repository: OneBusAway/onebusaway-gtfs-modules

Length of output: 14539


Add areas.txt to the recognized-files list GtfsMergerMain accepts Area via AreaMergeStrategy, so this section is currently missing a supported GTFS file.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/onebusaway-gtfs-merge-cli.md` around lines 56 - 66, The recognized GTFS
files list is missing support for areas, even though GtfsMergerMain already
accepts Area through AreaMergeStrategy. Update the documented supported-files
section to include areas.txt alongside the other recognized inputs, keeping the
list aligned with the merger’s actual capabilities and the Area-related symbols
used in the CLI.

Comment thread onebusaway-gtfs-merge-cli/pom.xml
@leonardehrenfried
leonardehrenfried merged commit 966fef3 into main Jul 6, 2026
10 checks passed
@leonardehrenfried

Copy link
Copy Markdown
Collaborator

Released as 14.1.0

@leonardehrenfried
leonardehrenfried deleted the docs-and-cli branch July 6, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants