Skip to content

Improve dump command: add --stdout, refactors, more tests#69

Merged
SkowronskiAndrew merged 10 commits into
mainfrom
dump-command-improvements
May 15, 2026
Merged

Improve dump command: add --stdout, refactors, more tests#69
SkowronskiAndrew merged 10 commits into
mainfrom
dump-command-improvements

Conversation

@SkowronskiAndrew
Copy link
Copy Markdown
Collaborator

@SkowronskiAndrew SkowronskiAndrew commented May 14, 2026

Summary

User-facing changes to the dump command:

  • --stdout writes the dump to standard output instead of a .txt file. Mutually exclusive with -o. Status messages and errors are routed to stderr so the dump stream is clean for piping. For archives, --stdout is refused when the archive contains more than one SerializedFile (no unambiguous way to deliver multiple files on a single stream).
  • External references are no longer included when filtering by -i or -t. With a filter the user is asking about a specific object, so the file-wide PPtr context isn't useful; the dedicated sf externalrefs command remains the way to list them. Behavior is unchanged for unfiltered dumps (backward compatible).
  • Help text for dump rewritten to make it clearer that the command dumps serialized objects (not the full byte content of an archive — archive extract is for that).

Refactors (no behavior change)

  • Program.Main() split into one BuildXCommand() helper per top-level command, so it's obvious where each command's args are defined.
  • TextDumperTool.Dump now takes a DumpOptions object instead of a long parameter list. The DumpFormat enum and the options live as nested types on TextDumperTool.
  • Dump() itself split into DumpArchive and DumpSerializedFile private 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

  • New DumpTests class covering --stdout behaviour in various cases with a specific reference file. This simple dedicated test class will make it easier to add more test coverage at dump evolves.
  • New DumpText_Stdout_WritesDumpToStdout test added to UnityDataToolAssetBundleTests — 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

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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 --stdout with stderr routing for status/errors and validation against -o.
  • Refactors TextDumperTool.Dump to use DumpOptions and 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.

Comment thread TextDumper/TextDumperTool.cs Outdated
Comment thread UnityDataTool/Program.cs
Comment thread TextDumper/TextDumperTool.cs
Comment thread Documentation/textdumper.md Outdated
Comment thread TextDumper/TextDumperTool.cs
Comment thread TextDumper/TextDumperTool.cs Outdated
Comment thread Documentation/command-dump.md
Comment thread UnityDataTool.Tests/UnityDataToolAssetBundleTests.cs
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
@SkowronskiAndrew SkowronskiAndrew marked this pull request as ready for review May 15, 2026 17:44
@SkowronskiAndrew SkowronskiAndrew merged commit 9483aa6 into main May 15, 2026
5 checks passed
@SkowronskiAndrew SkowronskiAndrew deleted the dump-command-improvements branch May 15, 2026 17:47
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