Skip to content

Commit 6788ecd

Browse files
Refactor Main() and arguments to Dump
Split Main() into individual methods for each command. Use a structure to pass options to TextDumperTool
1 parent cc67b4e commit 6788ecd

3 files changed

Lines changed: 259 additions & 245 deletions

File tree

Documentation/textdumper.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ file (AssetBundle or SerializedFile) into human-readable yaml-style text file.
55

66
## How to use
77

8-
The library consists of a single class called [TextDumperTool](../TextDumper/TextDumperTool.cs). It has a method named Dump and takes five parameters:
9-
* path (string): path of the data file.
10-
* outputPath (string): path where the output files will be created.
11-
* skipLargeArrays (bool): if true, the content of arrays larger than 1KB won't be dumped.
12-
* objectId (long, optional): if specified and not 0, only the object with this signed 64-bit id will be dumped. If 0 (default), all objects are dumped.
13-
* typeFilter (string, optional): if specified, only objects matching this type are dumped. Accepts a numeric ClassID (e.g. 114) or a type name (e.g. MonoBehaviour, case-insensitive).
8+
The library consists of a single class called [TextDumperTool](../TextDumper/TextDumperTool.cs). Call its `Dump` method, passing a `TextDumperTool.DumpOptions` object with the following properties:
9+
* `Format` (DumpFormat, optional): output format. Defaults to `Text`.
10+
* `Path` (string): path of the data file.
11+
* `OutputPath` (string): path where the output files will be created. Ignored when `ToStdout` is true.
12+
* `SkipLargeArrays` (bool): if true, the content of arrays larger than 1KB won't be dumped.
13+
* `ObjectId` (long, optional): if specified and not 0, only the object with this signed 64-bit id will be dumped. If 0 (default), all objects are dumped.
14+
* `TypeFilter` (string, optional): if specified, only objects matching this type are dumped. Accepts a numeric ClassID (e.g. 114) or a type name (e.g. MonoBehaviour, case-insensitive).
15+
* `ToStdout` (bool, optional): if true, the dump is written to standard output instead of a file. Refused for archives that contain more than one SerializedFile.
1416

1517
## How to interpret the output files
1618

TextDumper/TextDumperTool.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,34 @@ public class TextDumperTool
1414
SerializedFile m_SerializedFile;
1515
TextWriter m_Writer;
1616

17-
public int Dump(string path, string outputPath, bool skipLargeArrays, long objectId = 0, string typeFilter = null, bool toStdout = false)
17+
public enum DumpFormat
1818
{
19+
Text,
20+
}
21+
22+
public class DumpOptions
23+
{
24+
public DumpFormat Format { get; init; } = DumpFormat.Text;
25+
public string Path { get; init; }
26+
public string OutputPath { get; init; }
27+
public bool SkipLargeArrays { get; init; }
28+
public long ObjectId { get; init; }
29+
public string TypeFilter { get; init; }
30+
public bool ToStdout { get; init; }
31+
}
32+
33+
public int Dump(DumpOptions options)
34+
{
35+
var path = options.Path;
36+
var outputPath = options.OutputPath;
37+
var objectId = options.ObjectId;
38+
var typeFilter = options.TypeFilter;
39+
var toStdout = options.ToStdout;
40+
1941
if (string.IsNullOrWhiteSpace(typeFilter))
2042
typeFilter = null;
2143

22-
m_SkipLargeArrays = skipLargeArrays;
44+
m_SkipLargeArrays = options.SkipLargeArrays;
2345

2446
try
2547
{

0 commit comments

Comments
 (0)