Improve dump command: add --stdout, refactors, more tests#69
Merged
Conversation
Support easier piping.
Split Main() into individual methods for each command. Use a structure to pass options to TextDumperTool
Also exclude external references when using dump with filtering (by type or object)
Simplify the main entry point into dump so that archive and serialized file error handling and other details do not clutter the main flow.
The OutputSerializedFile() method made sense earlier in the file so that the implementation is going approximately from higher level down to lower level details Sorry for the code churn but this aid readability.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds stdout support and filtering behavior refinements for the dump command, while refactoring command construction and the text dumper API.
Changes:
- Adds
dump --stdoutwith stderr routing for status/errors and validation against-o. - Refactors
TextDumperTool.Dumpto useDumpOptionsand separates archive vs SerializedFile dumping. - Adds stdout-focused tests and updates dump/TextDumper documentation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
UnityDataTool/Program.cs |
Refactors command builders and wires new dump stdout/options handling. |
TextDumper/TextDumperTool.cs |
Implements stdout dumping, archive restrictions, and filtered External References behavior. |
UnityDataTool.Tests/DumpTests.cs |
Adds direct SerializedFile stdout behavior tests. |
UnityDataTool.Tests/UnityDataToolAssetBundleTests.cs |
Adds archive stdout golden-output comparison. |
Documentation/command-dump.md |
Documents --stdout usage and restrictions. |
Documentation/textdumper.md |
Updates TextDumper API documentation for DumpOptions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Listing all the options to Dump() is rather redundant, the important documentation is command-dump.md and its just a maintenance burden to also list them here.
- Fix typo (its -> it's) in DumpArchive comment - Document that filtered dumps omit External References (command-dump.md, textdumper.md) - Add tests: type-filter omits External References, --stdout/-o mutual exclusion error, multi-SerializedFile archive refusal (data.unity3d) - Assert no .txt file is written by --stdout in DumpText_Stdout_WritesDumpToStdout
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
User-facing changes to the
dumpcommand:--stdoutwrites the dump to standard output instead of a.txtfile. Mutually exclusive with-o. Status messages and errors are routed to stderr so the dump stream is clean for piping. For archives,--stdoutis refused when the archive contains more than one SerializedFile (no unambiguous way to deliver multiple files on a single stream).-ior-t. With a filter the user is asking about a specific object, so the file-wide PPtr context isn't useful; the dedicatedsf externalrefscommand remains the way to list them. Behavior is unchanged for unfiltered dumps (backward compatible).dumprewritten to make it clearer that the command dumps serialized objects (not the full byte content of an archive —archive extractis for that).Refactors (no behavior change)
Program.Main()split into oneBuildXCommand()helper per top-level command, so it's obvious where each command's args are defined.TextDumperTool.Dumpnow takes aDumpOptionsobject instead of a long parameter list. TheDumpFormatenum and the options live as nested types onTextDumperTool.Dump()itself split intoDumpArchiveandDumpSerializedFileprivate helpers; the main method is now a flat dispatcher.Note: the refactors cause some "churn" in the code but will benefit us in the long run as we add JSON support to dump command and continue to expand the available commands and arguments.
Tests
DumpTestsclass covering--stdoutbehaviour in various cases with a specific reference file. This simple dedicated test class will make it easier to add more test coverage atdumpevolves.DumpText_Stdout_WritesDumpToStdouttest added toUnityDataToolAssetBundleTests— captures stdout and byte-compares against the existing golden file (parameterised across the 5 Unity versions in the fixture). Any divergence between file-mode and stdout-mode output will fail.Documentation updated in
command-dump.md