Skip to content

Commit 31e99f9

Browse files
committed
restore --unpack-decompressed and --unpack-raw command for backward compatibility
1 parent 7177048 commit 31e99f9

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

Interface/Actions/UnpackAction.cs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ public enum UnpackingMode
2020

2121
public string Name => "--unpack";
2222

23-
public string[] Aliases => ["-u"];
23+
public string[] Aliases => ["-u", UnpackDecompressedAlias, UnpackRawAlias];
2424

2525
public string Description =>
26-
"Unpacks entire .PAK package into specified directory and attempts to process XNB assets";
26+
"Unpacks entire .PAK package into specified directory and attempts to process XNB assets.\n\n"
27+
+ $"The '{UnpackDecompressedAlias}' and '{UnpackRawAlias}' aliases are provided for backwards compatibility\n"
28+
+ $"and they reproduce the command behaviour with the '--mode' flags "
29+
+ $"'{ArgumentsOf(UnpackingMode.DecompressedXnb)}' "
30+
+ $"and '{ArgumentsOf(UnpackingMode.Raw)}' respectively.";
2731

2832
public Argument[] Arguments => [_pakFile, _destinationDirectory];
2933

@@ -48,11 +52,33 @@ public enum UnpackingMode
4852
CustomParser = CustomAliasedEnumParser<UnpackingMode>
4953
};
5054

55+
private const string UnpackDecompressedAlias = "--unpack-decompressed";
56+
57+
private const string UnpackRawAlias = "--unpack-raw";
58+
5159
public void Execute(ParseResult result)
5260
{
5361
var pakFile = result.GetRequiredValue(_pakFile);
5462
var destinationDirectory = result.GetRequiredValue(_destinationDirectory);
55-
var unpackingMode = result.GetValue(_unpackingMode);
63+
64+
UnpackingMode unpackingMode;
65+
switch (result.CommandResult.IdentifierToken.Value)
66+
{
67+
// For backward compatibility, the value of the "--mode" option
68+
// will be overwritten when using these older commands.
69+
case UnpackDecompressedAlias:
70+
Console.WriteLine($"Warning! The '{_unpackingMode.Name}' option will be ignored.");
71+
unpackingMode = UnpackingMode.DecompressedXnb;
72+
break;
73+
case UnpackRawAlias:
74+
Console.WriteLine($"Warning! The '{_unpackingMode.Name}' option will be ignored.");
75+
unpackingMode = UnpackingMode.Raw;
76+
break;
77+
default:
78+
unpackingMode = result.GetValue(_unpackingMode);
79+
break;
80+
}
81+
5682
var settings = new FormatConverterSettings
5783
{
5884
UseLegacyArtObjectBundle = result.GetValue(UseArtObjectLegacyBundles),

0 commit comments

Comments
 (0)