Repository navigation
Conversation
Adds a streaming JSONReader (marcjson.go) alongside the existing binary Reader and XMLReader, so all three input formats can be decoded one record at a time instead of requiring ParseJSON's whole-document slurp. cmd/marcconv is a new CLI built on the shared Next()/Write() shape of these readers/writers, converting -from one format -to another (formats guessed from file extensions when not given explicitly). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
flag.Parse stops scanning at the first non-flag argument, so the exact
usage shown in the README ("marcconv in.dat -o out.json") was rejected
with a usage error — -o and its value were misread as extra positional
args. Reorder recognized flag tokens ahead of positionals before parsing
so flags work regardless of where they sit relative to the input file.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cmd/marcconv, a CLI that streams MARC21 records between binary MARC, MARCXML, and MARC-in-JSON (and out to MARCMaker text), converting one record at a time.JSONReaderinmarcjson.goso JSON input can be decoded record-by-record like the existing binaryReader/XMLReader, instead of requiringParseJSON's whole-document slurp. RefactorssanitizeLenientJSONto reuse the same streaming control-character filter.-from/-toare guessed from file extensions (.mrc/.marc/.dat,.xml,.json,.txt) when not given explicitly; required when reading from stdin.Test plan
go build ./...go vet ./...gofmt -l .(clean)go test ./...(112 passed)marcconv, verified identical MARCMaker text output (leader byte 9 correctly flips to reflect MARC-8 → Unicode transcoding, per spec)-from/-to,-oextension-based format guessing, missing-fromon stdin exits with usage error🤖 Generated with Claude Code