[CLI] Add support for multiple file loading

This commit is contained in:
VaDiM
2025-05-29 05:01:59 +03:00
parent 548f8a52cf
commit 7da68aedff
2 changed files with 14 additions and 10 deletions

View File

@ -73,7 +73,7 @@ namespace AssetStudioCLI.Options
public static bool isParsed; public static bool isParsed;
public static bool showHelp; public static bool showHelp;
public static string[] cliArgs; public static string[] cliArgs;
public static string inputPath; public static List<string> inputPathList;
public static FilterBy filterBy; public static FilterBy filterBy;
private static Dictionary<string, string> optionsDict; private static Dictionary<string, string> optionsDict;
private static Dictionary<string, string> flagsDict; private static Dictionary<string, string> flagsDict;
@ -159,7 +159,7 @@ namespace AssetStudioCLI.Options
isParsed = false; isParsed = false;
showHelp = false; showHelp = false;
cliArgs = null; cliArgs = null;
inputPath = ""; inputPathList = new List<string>();
filterBy = FilterBy.None; filterBy = FilterBy.None;
optionsDict = new Dictionary<string, string>(); optionsDict = new Dictionary<string, string>();
flagsDict = new Dictionary<string, string>(); flagsDict = new Dictionary<string, string>();
@ -543,12 +543,16 @@ namespace AssetStudioCLI.Options
if (!args[0].StartsWith("-")) if (!args[0].StartsWith("-"))
{ {
inputPath = Path.GetFullPath(args[0]).Replace("\"", ""); foreach (var path in ValueSplitter(args[0]))
if (!Directory.Exists(inputPath) && !File.Exists(inputPath))
{ {
Console.WriteLine($"{"Error:".Color(brightRed)} Invalid input path \"{args[0].Color(brightRed)}\".\n" + var fullPath = Path.GetFullPath(path).Replace("\"", "");
$"Specified file or folder was not found. The input path must be specified as the first argument."); if (!Directory.Exists(fullPath) && !File.Exists(fullPath))
return; {
Console.WriteLine($"{"Error:".Color(brightRed)} Invalid input path \"{fullPath.Color(brightRed)}\".\n" +
$"Specified file or folder was not found. The input path must be specified as the first argument.");
return;
}
inputPathList.Add(fullPath);
} }
} }
else else
@ -1304,7 +1308,7 @@ namespace AssetStudioCLI.Options
{ {
sb.AppendLine($"# Parse Assets Using TypeTree: {!f_avoidLoadingViaTypetree.Value}"); sb.AppendLine($"# Parse Assets Using TypeTree: {!f_avoidLoadingViaTypetree.Value}");
} }
sb.AppendLine($"# Input Path: \"{inputPath}\""); sb.AppendLine($"# Input Path: \"{string.Join("\"\n- \"", inputPathList)}\"");
if (o_workMode.Value != WorkMode.Info) if (o_workMode.Value != WorkMode.Info)
{ {
sb.AppendLine($"# Output Path: \"{o_outputFolder}\""); sb.AppendLine($"# Output Path: \"{o_outputFolder}\"");

View File

@ -39,7 +39,7 @@ namespace AssetStudioCLI
public static void ExtractBundles() public static void ExtractBundles()
{ {
var extractedCount = 0; var extractedCount = 0;
var path = CLIOptions.inputPath; var path = CLIOptions.inputPathList[0];
var savePath = CLIOptions.o_outputFolder.Value; var savePath = CLIOptions.o_outputFolder.Value;
Progress.Reset(); Progress.Reset();
if (Directory.Exists(path)) if (Directory.Exists(path))
@ -170,7 +170,7 @@ namespace AssetStudioCLI
{ {
assetsManager.SetAssetFilter(CLIOptions.o_exportAssetTypes.Value); assetsManager.SetAssetFilter(CLIOptions.o_exportAssetTypes.Value);
} }
assetsManager.LoadFilesAndFolders(CLIOptions.inputPath); assetsManager.LoadFilesAndFolders(out _, CLIOptions.inputPathList);
if (assetsManager.assetsFileList.Count == 0) if (assetsManager.assetsFileList.Count == 0)
{ {
Logger.Warning("No Unity file can be loaded."); Logger.Warning("No Unity file can be loaded.");