Skip to content

Commit ce5b610

Browse files
authored
Print All option for info
`-a`/`--all` for irdkit info command
1 parent 048d70b commit ce5b610

File tree

6 files changed

+143
-20
lines changed

6 files changed

+143
-20
lines changed

.github/workflows/build.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Build
2+
3+
on:
4+
push: {}
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
strategy:
11+
matrix:
12+
project: [IRDKit]
13+
runtime: [win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64, osx-arm64]
14+
framework: [net8.0]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
submodules: 'true'
20+
21+
- name: Setup .NET
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: 9.0.x
25+
26+
- name: Restore dependencies
27+
run: dotnet restore
28+
29+
- name: Build
30+
run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c Release -p:DebugType=None -p:DebugSymbols=false
31+
32+
- name: Upload build
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}
36+
path: ${{ matrix.project }}/bin/Release/${{ matrix.framework }}/${{ matrix.runtime }}/publish/*

IRDKit/IRDKit.csproj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@
55
<OutputType>Exe</OutputType>
66
<TargetName>irdkit</TargetName>
77
<AssemblyName>irdkit</AssemblyName>
8-
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
8+
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
99
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
1010
<CheckEolTargetFramework>false</CheckEolTargetFramework>
1111
<LangVersion>latest</LangVersion>
1212
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
13+
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
14+
<PublishSingleFile>true</PublishSingleFile>
15+
<SelfContained>false</SelfContained>
1316
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
14-
<Version>0.9.3</Version>
17+
<Version>0.9.5</Version>
1518

1619
<!-- Package Properties -->
1720
<Authors>Deterous</Authors>
1821
<Description>Library for ISO Rebuild Data</Description>
19-
<Copyright>Copyright (c) Deterous 2023-2024</Copyright>
22+
<Copyright>Copyright (c) Deterous 2023-2025</Copyright>
2023
<PackageReadmeFile>README.md</PackageReadmeFile>
2124
<RepositoryUrl>https://github.com/Deterous/LibIRD</RepositoryUrl>
2225
<RepositoryType>git</RepositoryType>
@@ -30,8 +33,8 @@
3033

3134
<ItemGroup>
3235
<PackageReference Include="CommandLineParser" Version="2.9.1" />
33-
<PackageReference Include="SabreTools.Hashing" Version="1.4.0" />
34-
<PackageReference Include="SabreTools.RedumpLib" Version="1.5.2" />
36+
<PackageReference Include="SabreTools.Hashing" Version="1.5.0" />
37+
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.0" />
3538
</ItemGroup>
3639

3740
<ItemGroup>

IRDKit/Program.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public class InfoOptions
5959
[Option('o', "output", HelpText = "Path to the text or json file to be created (will overwrite)")]
6060
public string OutPath { get; set; }
6161

62+
[Option('a', "all", HelpText = "Print the entire contents of the IRD")]
63+
public bool All { get; set; }
64+
6265
[Option('j', "json", HelpText = "Print IRD or ISO information as a JSON object")]
6366
public bool Json { get; set; }
6467

@@ -283,7 +286,7 @@ private static void Run(object args)
283286
string lastIRD = irdFiles.Last();
284287
foreach (string file in irdFiles)
285288
{
286-
PrintInfo(file, opt.Json, (noISO && file.Equals(lastIRD)), opt.OutPath);
289+
PrintInfo(file, opt.Json, (noISO && file.Equals(lastIRD)), opt.OutPath, opt.All);
287290
}
288291

289292

@@ -325,7 +328,7 @@ private static void Run(object args)
325328
}
326329

327330
// Print info from given file
328-
PrintInfo(filePath, opt.Json, true, opt.OutPath);
331+
PrintInfo(filePath, opt.Json, true, opt.OutPath, opt.All);
329332

330333
if (opt.OutPath != null && opt.OutPath != "")
331334
Console.WriteLine($"Info saved to {opt.OutPath}");
@@ -464,8 +467,9 @@ private static void Run(object args)
464467
/// </summary>
465468
/// <param name="inPath">File to retrieve info from</param>
466469
/// <param name="json">Whether to format output as JSON (true) or plain text (false)</param>
470+
/// <param name="single">Whether to print a single JSON object or not</param>
467471
/// <param name="outPath">File to output info to</param>
468-
public static void PrintInfo(string inPath, bool json, bool single = true, string outPath = null)
472+
public static void PrintInfo(string inPath, bool json, bool single = true, string outPath = null, bool printAll = false)
469473
{
470474
// Check if file is an ISO
471475
bool isISO = String.Compare(Path.GetExtension(inPath), ".iso", StringComparison.OrdinalIgnoreCase) == 0;
@@ -492,10 +496,10 @@ public static void PrintInfo(string inPath, bool json, bool single = true, strin
492496
File.AppendAllText(outPath, $"\"{Path.GetFileName(inPath)}\": ");
493497
else
494498
Console.Write($"\"{Path.GetFileName(inPath)}\": ");
495-
ird.PrintJson(outPath, single);
499+
ird.PrintJson(outPath, single, printAll);
496500
}
497501
else
498-
IRD.Read(inPath).Print(outPath, Path.GetFileName(inPath));
502+
IRD.Read(inPath).Print(outPath, Path.GetFileName(inPath), printAll);
499503

500504
if (json)
501505
return;
@@ -518,6 +522,7 @@ public static void PrintInfo(string inPath, bool json, bool single = true, strin
518522
/// </summary>
519523
/// <param name="isoPath">Path to ISO file</param>
520524
/// <param name="json">Whether to format output as JSON (true) or plain text (false)</param>
525+
/// <param name="single">Whether to print a single JSON object or not</param>
521526
/// <param name="outPath">File to output info to</param>
522527
/// <exception cref="FileNotFoundException"></exception>
523528
/// <exception cref="InvalidFileSystemException"></exception>

IRDKit/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ For all options, run `irdkit help info`
3232
To print info about an ISO or IRD file, run `irdkit info game.iso` or `irdkit info game.ird`
3333
The info can be printed to a file, e.g. `-o out.txt` or `--output=`
3434
The info can be formatted as a JSON with `-j` or `--json`
35+
To print all info in the IRD use `-a` or `--all`
3536

3637
## Comparing IRDs
3738

LibIRD/IRD.cs

Lines changed: 86 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,9 @@ public static IRD Read(string irdPath)
15611561
/// Prints IRD fields to console
15621562
/// </summary>
15631563
/// <param name="printPath">Optional path to save file to</param>
1564-
public void Print(string printPath = null, string irdName = null)
1564+
/// <param name="printAll">Optionally print IRD name in output header</param>
1565+
/// <param name="printAll">Optionally print all IRD data</param>
1566+
public void Print(string printPath = null, string irdName = null, bool printAll = false)
15651567
{
15661568
// Build string from parameters
15671569
StringBuilder printText = new();
@@ -1579,11 +1581,38 @@ public void Print(string printPath = null, string irdName = null)
15791581
printText.AppendLine($"PUP Version: {SystemVersion}");
15801582
printText.AppendLine($"Disc Version: {DiscVersion}");
15811583
printText.AppendLine($"App Version: {AppVersion}");
1584+
if (printAll)
1585+
{
1586+
printText.AppendLine($"Header: {ByteArrayToHexString(Header)}");
1587+
printText.AppendLine($"Footer: {ByteArrayToHexString(Footer)}");
1588+
}
15821589
printText.AppendLine($"Regions: {RegionCount}");
1590+
if (printAll)
1591+
{
1592+
for (int i = 0; i < RegionCount; i++)
1593+
{
1594+
printText.Append($" Region {i} : ");
1595+
if (RegionHashes[i] == null)
1596+
printText.AppendLine($"{ByteArrayToHexString(NullMD5)}");
1597+
else
1598+
printText.AppendLine($"{ByteArrayToHexString(RegionHashes[i])}");
1599+
}
1600+
}
15831601
printText.AppendLine($"Files: {FileCount}");
1584-
if (ExtraConfig != 0x0000)
1602+
if (printAll)
1603+
{
1604+
for (int i = 0; i < FileCount; i++)
1605+
{
1606+
printText.Append($" {FileKeys[i]:X7} : ");
1607+
if (FileHashes[i] == null)
1608+
printText.AppendLine($"{ByteArrayToHexString(NullMD5)}");
1609+
else
1610+
printText.AppendLine($"{ByteArrayToHexString(FileHashes[i])}");
1611+
}
1612+
}
1613+
if (printAll || ExtraConfig != 0x0000)
15851614
printText.AppendLine($"Extra Config: {ExtraConfig:X4}");
1586-
if (Attachments != 0x0000)
1615+
if (printAll || Attachments != 0x0000)
15871616
printText.AppendLine($"Attachments: {Attachments:X4}");
15881617
printText.AppendLine($"Unique ID: {UID:X8}");
15891618
printText.AppendLine($"Data 1 Key: {ByteArrayToHexString(Data1Key)}");
@@ -1610,7 +1639,9 @@ public void Print(string printPath = null, string irdName = null)
16101639
/// Prints IRD fields to a json object
16111640
/// </summary>
16121641
/// <param name="jsonPath">Optionally print to json file</param>
1613-
public void PrintJson(string jsonPath = null, bool single = true)
1642+
/// <param name="single">Optionally print single object (no trailing comma)</param>
1643+
/// <param name="printAll">Optionally print all IRD data</param>
1644+
public void PrintJson(string jsonPath = null, bool single = true, bool printAll = false)
16141645
{
16151646
// Build string from parameters
16161647
StringBuilder json = new();
@@ -1624,11 +1655,58 @@ public void PrintJson(string jsonPath = null, bool single = true)
16241655
json.AppendLine($" \"PUP Version\": \"{SystemVersion}\",");
16251656
json.AppendLine($" \"Disc Version\": \"{DiscVersion}\",");
16261657
json.AppendLine($" \"App Version\": \"{AppVersion}\",");
1627-
json.AppendLine($" \"Regions\": \"{RegionCount}\",");
1628-
json.AppendLine($" \"Files\": \"{FileCount}\",");
1629-
if (ExtraConfig != 0x0000)
1658+
if (printAll)
1659+
{
1660+
json.AppendLine($" \"Header\": \"{ByteArrayToHexString(Header)}\",");
1661+
json.AppendLine($" \"Footer\": \"{ByteArrayToHexString(Footer)}\",");
1662+
}
1663+
if (!printAll)
1664+
json.AppendLine($" \"Regions\": \"{RegionCount}\",");
1665+
else
1666+
{
1667+
json.Append($" \"Regions\": [ ");
1668+
for (int i = 0; i < RegionCount - 1; i++)
1669+
{
1670+
if (RegionHashes[i] == null)
1671+
json.Append($"\"{ByteArrayToHexString(NullMD5)}\", ");
1672+
else
1673+
json.Append($"\"{ByteArrayToHexString(RegionHashes[i])}\", ");
1674+
}
1675+
if (RegionCount > 0)
1676+
{
1677+
if (RegionHashes[RegionCount - 1] == null)
1678+
json.Append($"\"{ByteArrayToHexString(NullMD5)}\"");
1679+
else
1680+
json.Append($"\"{ByteArrayToHexString(RegionHashes[RegionCount - 1])}\"");
1681+
}
1682+
json.AppendLine(" ],");
1683+
}
1684+
if(!printAll)
1685+
json.AppendLine($" \"Files\": \"{FileCount}\",");
1686+
else
1687+
{
1688+
json.Append($" \"Files\": [ ");
1689+
for (int i = 0; i < RegionCount - 1; i++)
1690+
{
1691+
json.Append($" \"{FileKeys[i]}\" : ");
1692+
if (RegionHashes[i] == null)
1693+
json.Append($"\"{ByteArrayToHexString(NullMD5)}\", ");
1694+
else
1695+
json.Append($"\"{ByteArrayToHexString(FileHashes[i])}\", ");
1696+
}
1697+
if (FileCount > 0)
1698+
{
1699+
json.Append($" \"{FileKeys[FileCount - 1]}\" : ");
1700+
if (FileHashes[FileCount - 1] == null)
1701+
json.Append($"\"{ByteArrayToHexString(NullMD5)}\"");
1702+
else
1703+
json.Append($"\"{ByteArrayToHexString(FileHashes[FileCount - 1])}\"");
1704+
}
1705+
json.AppendLine(" ],");
1706+
}
1707+
if (printAll || ExtraConfig != 0x0000)
16301708
json.AppendLine($" \"Extra Config\": \"{ExtraConfig:X4}\",");
1631-
if (Attachments != 0x0000)
1709+
if (printAll || Attachments != 0x0000)
16321710
json.AppendLine($" \"Attachments\": \"{Attachments:X4}\",");
16331711
json.AppendLine($" \"Unique ID\": \"{UID:X8}\",");
16341712
json.AppendLine($" \"Data 1 Key\": \"{ByteArrayToHexString(Data1Key)}\",");

LibIRD/LibIRD.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<LangVersion>latest</LangVersion>
88
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
99
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
10-
<Version>0.9.3</Version>
10+
<Version>0.9.4</Version>
1111
<PackageOutputPath>../nupkg</PackageOutputPath>
1212

1313
<!-- Avoid inexact read with 'System.IO.Stream.Read' -->
@@ -16,7 +16,7 @@
1616
<!-- Package Properties -->
1717
<Authors>Deterous</Authors>
1818
<Description>Library for ISO Rebuild Data</Description>
19-
<Copyright>Copyright (c) Deterous 2023-2024</Copyright>
19+
<Copyright>Copyright (c) Deterous 2023-2025</Copyright>
2020
<PackageReadmeFile>README.md</PackageReadmeFile>
2121
<RepositoryUrl>https://github.com/Deterous/LibIRD/</RepositoryUrl>
2222
<RepositoryType>git</RepositoryType>

0 commit comments

Comments
 (0)