Skip to content

Commit 8368273

Browse files
committed
Add comprehensive CLI documentation: commands, examples, and custom format handlers
1 parent d17582d commit 8368273

10 files changed

Lines changed: 1562 additions & 143 deletions

File tree

CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,49 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
66

77
---
88

9+
## [0.3.0] - 2026-01-07
10+
11+
### Added
12+
13+
#### CLI Module (`aether-datafixers-cli`)
14+
15+
New command-line interface for data migration without writing Java code.
16+
17+
**Commands:**
18+
- `migrate` — Migrate data files from one schema version to another
19+
- `validate` — Check if files need migration without modifying them
20+
- `info` — Display version info, available formats, and bootstrap details
21+
22+
**Core Features:**
23+
- Batch processing of multiple files with shell glob expansion
24+
- Auto-detection of source version from configurable data field path
25+
- In-place file modification with automatic `.bak` backup
26+
- Output to stdout, file, or directory
27+
- Pretty-printed or compact JSON output
28+
- Migration reports in text or JSON format
29+
- Verbose mode with detailed progress and stack traces
30+
- Fail-fast or continue-on-error modes
31+
- CI/CD friendly exit codes (0=success, 1=error, 2=migration needed)
32+
33+
**Format Handler System:**
34+
- `FormatHandler<T>` — SPI for pluggable serialization formats
35+
- `FormatRegistry` — ServiceLoader-based handler discovery
36+
- `json-gson` — JSON format using Google Gson (default)
37+
- `json-jackson` — JSON format using Jackson Databind
38+
39+
**Utilities:**
40+
- `BootstrapLoader` — Reflective loading of DataFixerBootstrap implementations
41+
- `VersionExtractor` — Extract version from nested JSON paths (dot notation)
42+
- `ReportFormatter` — Text and JSON migration report formatting
43+
- `TextReportFormatter` — Human-readable single-line reports
44+
- `JsonReportFormatter` — Machine-readable JSON reports
45+
46+
**Exceptions:**
47+
- `BootstrapLoadException` — Bootstrap class loading failures
48+
- `FormatParseException` — Input parsing failures
49+
50+
---
51+
952
## [0.2.0] - 2026-01-07
1053

1154
### Added

docs/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ Test your DataFixes and migrations with the Testkit module:
8484
- [QuickFix Factories](testkit/quick-fix.md) — Factory methods for common fix patterns
8585
- [Mock Schemas](testkit/mock-schemas.md) — Mock schema utilities
8686

87+
### Command-Line Interface
88+
89+
Migrate and validate data files from the command line:
90+
91+
- [CLI Overview](cli/index.md) — Introduction to the CLI tool
92+
- [Installation](cli/installation.md) — Building and running the CLI
93+
- [Command Reference](cli/commands.md) — Detailed command documentation
94+
- [Format Handlers](cli/format-handlers.md) — Custom format handler development
95+
- [Examples](cli/examples.md) — Practical usage examples
96+
8797
### Advanced Topics
8898

8999
For experienced users:
@@ -109,6 +119,7 @@ For experienced users:
109119
| `aether-datafixers-api` | Core interfaces and API contracts |
110120
| `aether-datafixers-core` | Default implementations |
111121
| `aether-datafixers-codec` | GsonOps, JacksonOps implementations |
122+
| `aether-datafixers-cli` | Command-line interface for data migration |
112123
| `aether-datafixers-testkit` | Testing utilities for DataFix, Schema, and migration testing |
113124
| `aether-datafixers-examples` | Practical usage examples |
114125
| `aether-datafixers-bom` | Bill of Materials for version management |

docs/appendix/changelog.md

Lines changed: 54 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,70 @@
11
# Documentation Changelog
22

3-
History of documentation updates.
3+
History of documentation updates. For code changes, see the main [CHANGELOG.md](../../CHANGELOG.md).
44

5-
## Version 0.2.0
6-
7-
Extended rules, testkit module, and migration diagnostics release.
8-
9-
### Migration Diagnostics
10-
11-
New opt-in diagnostic system for capturing structured reports during migrations:
12-
13-
**Core API (`aether-datafixers-api`):**
14-
- `DiagnosticOptions` — Configuration for diagnostic capture (snapshots, rule details, limits)
15-
- `DiagnosticContext` — Context interface extending `DataFixerContext` for diagnostic migrations
16-
- `MigrationReport` — Immutable report with timing, fixes, rules, warnings, and snapshots
17-
- `FixExecution` — Record of individual fix executions with timing and rule applications
18-
- `RuleApplication` — Record of individual rule applications within a fix
19-
20-
**Implementation (`aether-datafixers-core`):**
21-
- `DiagnosticContextImpl` — Full implementation with logging and message formatting
22-
- `MigrationReportImpl` — Immutable report implementation with builder
23-
- `DiagnosticRuleWrapper` — Rule wrapper for capturing rule-level timing
24-
25-
**Features:**
26-
- Zero overhead when diagnostics are not enabled (opt-in via `DiagnosticContext`)
27-
- Configurable snapshot capture with truncation limits
28-
- Per-fix and per-rule timing measurements
29-
- Warning emission from DataFix implementations
30-
- Summary generation for quick overview
31-
32-
**Presets:**
33-
- `DiagnosticOptions.defaults()` — Full diagnostics with snapshots and rule details
34-
- `DiagnosticOptions.minimal()` — Timing only, minimal overhead
35-
36-
### Extended Rewrite Rules
37-
38-
New convenience methods in `Rules` class for common transformation patterns:
39-
40-
**Core Rules:**
41-
- `dynamicTransform(name, ops, fn)` — Custom Dynamic transformation
42-
- `setField(ops, field, value)` — Set field (overwrites existing)
5+
---
436

44-
**Batch Operations:**
45-
- `renameFields(ops, map)` — Batch rename multiple fields
46-
- `removeFields(ops, fields...)` — Batch remove multiple fields
7+
## Version 0.3.0
478

48-
**Grouping and Moving:**
49-
- `groupFields(ops, target, fields...)` — Group fields into nested object
50-
- `flattenField(ops, field)` — Flatten nested object to root
51-
- `moveField(ops, source, target)` — Move field between paths
52-
- `copyField(ops, source, target)` — Copy field (keeps original)
9+
### New Section: CLI Module
5310

54-
**Path-Based Operations:**
55-
- `transformFieldAt(ops, path, fn)` — Transform at nested path
56-
- `renameFieldAt(ops, path, newName)` — Rename at nested path
57-
- `removeFieldAt(ops, path)` — Remove at nested path
58-
- `addFieldAt(ops, path, value)` — Add at nested path
11+
Added complete documentation for the new CLI module:
5912

60-
**Conditional Rules:**
61-
- `ifFieldExists(ops, field, rule)` — Apply rule if field exists
62-
- `ifFieldMissing(ops, field, rule)` — Apply rule if field missing
63-
- `ifFieldEquals(ops, field, value, rule)` — Apply rule if field equals value
13+
- [CLI Overview](../cli/index.md) — Introduction, quick start, and workflow diagram
14+
- [Installation](../cli/installation.md) — Build instructions, aliases, classpath setup
15+
- [Command Reference](../cli/commands.md) — Detailed options for migrate, validate, info
16+
- [Format Handlers](../cli/format-handlers.md) — Custom format handler development guide
17+
- [Examples](../cli/examples.md) — 11 practical usage scenarios (CI/CD, Docker, scripting)
6418

65-
### High-Performance APIs
19+
### Updated Pages
6620

67-
New APIs for optimized transformations:
21+
- [Main README](../README.md) — Added CLI module to navigation and module table
22+
- [Installation Guide](../getting-started/installation.md) — Added CLI module to overview table
6823

69-
**BatchTransform:**
70-
- `Rules.batch(ops, builder)` — Apply multiple operations in single encode/decode cycle
71-
- `BatchTransform.rename(from, to)` — Rename field in batch
72-
- `BatchTransform.remove(field)` — Remove field in batch
73-
- `BatchTransform.set(field, valueSupplier)` — Set field in batch
74-
- `BatchTransform.transform(field, fn)` — Transform field in batch
75-
- `BatchTransform.addIfMissing(field, valueSupplier)` — Add if missing in batch
24+
---
7625

77-
**Single-Pass Conditionals:**
78-
- `Rules.conditionalTransform(ops, predicate, transform)` — General conditional
79-
- `Rules.ifFieldExists(ops, field, transform)` — Function overload (single-pass)
80-
- `Rules.ifFieldMissing(ops, field, transform)` — Function overload (single-pass)
81-
- `Rules.ifFieldEquals(ops, field, value, transform)` — Function overload (single-pass)
26+
## Version 0.2.0
8227

83-
### Performance Optimizations
28+
### New Section: Testkit Module
8429

85-
Internal optimizations with no API changes:
30+
Added complete documentation for the testkit module:
8631

87-
- Path parsing uses character-based parsing with memoization cache
88-
- `DataFixRegistry.getFixes()` pre-allocates result list
89-
- `DataFixerImpl` moves validation to registration time
90-
- Reduced allocations in hot paths
32+
- [Testkit Overview](../testkit/index.md) — Introduction to testing utilities
33+
- [Test Data Builders](../testkit/test-data-builders.md) — Fluent API for test data
34+
- [Custom Assertions](../testkit/assertions.md) — AssertJ assertions for Dynamic, DataResult, Typed
35+
- [DataFixTester](../testkit/datafix-tester.md) — Test harness for isolated DataFix testing
36+
- [QuickFix Factories](../testkit/quick-fix.md) — Factory methods for common fix patterns
37+
- [Mock Schemas](../testkit/mock-schemas.md) — Mock schema utilities
9138

9239
### New How-To Guides
9340

9441
- [Batch Operations](../how-to/batch-operations.md) — Rename/remove multiple fields
9542
- [Group Fields](../how-to/group-fields.md) — Grouping and flattening structures
9643
- [Conditional Rules](../how-to/conditional-rules.md) — Conditional rule application
44+
- [Use Diagnostics](../how-to/use-diagnostics.md) — Migration diagnostics guide
45+
- [Test Migrations](../how-to/test-migrations.md) — Testing migrations with testkit
9746

98-
### Testkit Module
99-
100-
New module `aether-datafixers-testkit` for testing migrations:
47+
### Updated Pages
10148

102-
- `TestData` — Fluent test data builders
103-
- `AetherAssertions` — Custom AssertJ assertions for Dynamic, DataResult, Typed
104-
- `DataFixTester` — Test harness for individual DataFix implementations
105-
- `MigrationTester` — Test harness for complete migration chains
106-
- `SchemaTester` — Test harness for Schema validation
107-
- `QuickFix` — Factory methods for common fix patterns
108-
- `MockSchemas` — Factory for mock Schema instances
109-
- `RecordingContext` / `AssertingContext` — Test contexts
110-
111-
### Documentation Updates
112-
113-
- Added [Use Diagnostics](../how-to/use-diagnostics.md) guide for migration diagnostics
114-
- Updated [Rewrite Rules](../concepts/rewrite-rules.md) with extended rules section
115-
- Updated [Concepts Index](../concepts/index.md) with extended rules examples
116-
- Updated [How-To Index](../how-to/index.md) with new guides
117-
- Added [Test Migrations](../how-to/test-migrations.md) guide
118-
- Added [Testkit documentation](../testkit/index.md) section
119-
- Updated [Glossary](glossary.md) with testkit terms
49+
- [Rewrite Rules](../concepts/rewrite-rules.md) — Extended rules section
50+
- [Concepts Index](../concepts/index.md) — Extended rules examples
51+
- [How-To Index](../how-to/index.md) — Links to new guides
52+
- [Glossary](glossary.md) — Testkit terminology
12053

12154
---
12255

12356
## Version 0.1.0
12457

125-
Initial documentation release covering:
58+
### Initial Documentation
59+
60+
Complete documentation covering all modules and concepts:
12661

127-
### Getting Started
128-
- Installation guide with Maven, Gradle, BOM
62+
**Getting Started:**
63+
- Installation (Maven, Gradle, BOM)
12964
- Quick start tutorial
13065
- First migration walkthrough
13166

132-
### Core Concepts
67+
**Core Concepts:**
13368
- Architecture overview
13469
- DataVersion and TypeReference
13570
- Schema and Type systems
@@ -139,64 +74,42 @@ Initial documentation release covering:
13974
- DSL reference
14075
- Rewrite rules
14176
- DataResult error handling
142-
- Thread safety guarantees
77+
- Thread safety
14378

144-
### Optics
79+
**Optics:**
14580
- Lens, Prism, Iso
14681
- Affine, Traversal, Getter
14782
- Finder for Dynamic navigation
14883

149-
### Tutorials
150-
- Basic migration
151-
- Multi-version migration chains
84+
**Tutorials:**
85+
- Basic and multi-version migrations
15286
- Schema inheritance
153-
- Codec usage
154-
- RecordCodecBuilder
87+
- Codec usage and RecordCodecBuilder
15588
- Polymorphic data
15689
- Nested transformations
15790
- Custom DynamicOps
15891

159-
### How-To Guides
92+
**How-To Guides:**
16093
- Field operations (rename, add, remove, transform)
161-
- Restructuring data
162-
- Type conversion
94+
- Restructuring, type conversion
16395
- Optional and unknown fields
164-
- Composing fixes
165-
- Debugging and testing
166-
- Logging migrations
167-
- Finder usage
168-
- Bootstrap creation
96+
- Composing fixes, debugging, logging
97+
- Finder usage, bootstrap creation
16998
- Gson integration
17099

171-
### Examples
172-
- Complete game data example
173-
- User profile migration
174-
- Configuration migration
100+
**Examples:**
101+
- Game data, user profile, configuration
175102
- Entity polymorphism
176103

177-
### API Reference
178-
- Complete API documentation
179-
- All packages covered
180-
- Method signatures and examples
181-
182-
### Advanced Topics
183-
- Traversal strategies
184-
- Custom optics
185-
- Recursive types
186-
- Performance optimization
187-
- Concurrent migrations
188-
- Format conversion
104+
**Advanced Topics:**
105+
- Traversal strategies, custom optics
106+
- Recursive types, performance
107+
- Concurrent migrations, format conversion
189108
- Framework extension
190109

191-
### Troubleshooting
192-
- Common errors
193-
- Debugging tips
194-
- FAQ
195-
196-
### Appendix
197-
- Glossary
198-
- Type theory primer
199-
- DFU comparison
110+
**Reference:**
111+
- Troubleshooting, common errors, FAQ
112+
- Glossary, type theory primer, DFU comparison
200113

201114
---
202115

@@ -206,4 +119,3 @@ To suggest documentation improvements:
206119
1. Open an issue on GitHub
207120
2. Describe the improvement
208121
3. Provide examples if applicable
209-

0 commit comments

Comments
 (0)