Utility changes to support extracting a zip relative to a mod. Can also be used to install new mods.
This commit is contained in:
@@ -52,6 +52,24 @@ namespace OpenRA.Utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ExtractZip(string argValue)
|
||||||
|
{
|
||||||
|
string[] args = argValue.Split(',');
|
||||||
|
|
||||||
|
if (args.Length != 3)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error: invalid syntax");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string zipFile = args[0];
|
||||||
|
string mod = args[1];
|
||||||
|
string path = args[2];
|
||||||
|
|
||||||
|
if (!File.Exists(zipFile)) { Console.WriteLine("Error: Could not find {0}", zipFile); return; }
|
||||||
|
string dest = "mods{0}{1}{0}{2}".F(Path.DirectorySeparatorChar,mod,path);
|
||||||
|
new ZipInputStream(File.OpenRead(zipFile)).ExtractZip(dest);
|
||||||
|
}
|
||||||
|
|
||||||
public static void DownloadUrl(string argValue)
|
public static void DownloadUrl(string argValue)
|
||||||
{
|
{
|
||||||
string[] args = argValue.Split(',');
|
string[] args = argValue.Split(',');
|
||||||
@@ -170,11 +188,5 @@ namespace OpenRA.Utility
|
|||||||
|
|
||||||
Console.WriteLine(n.Value);
|
Console.WriteLine(n.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InstallMod(string zipFile)
|
|
||||||
{
|
|
||||||
if (!File.Exists(zipFile)) { Console.WriteLine("Error: Could not find {0}", zipFile); return; }
|
|
||||||
new ZipInputStream(File.OpenRead(zipFile)).ExtractZip("mods");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ namespace OpenRA.Utility
|
|||||||
argCallbacks.Add("--mod-info", Command.ListModInfo);
|
argCallbacks.Add("--mod-info", Command.ListModInfo);
|
||||||
argCallbacks.Add("-i", Command.ListModInfo);
|
argCallbacks.Add("-i", Command.ListModInfo);
|
||||||
argCallbacks.Add("--download-url", Command.DownloadUrl);
|
argCallbacks.Add("--download-url", Command.DownloadUrl);
|
||||||
|
argCallbacks.Add("--extract-zip", Command.ExtractZip);
|
||||||
argCallbacks.Add("--install-ra-packages", Command.InstallRAPackages);
|
argCallbacks.Add("--install-ra-packages", Command.InstallRAPackages);
|
||||||
argCallbacks.Add("--install-cnc-packages", Command.InstallCncPackages);
|
argCallbacks.Add("--install-cnc-packages", Command.InstallCncPackages);
|
||||||
argCallbacks.Add("--settings-value", Command.Settings);
|
argCallbacks.Add("--settings-value", Command.Settings);
|
||||||
argCallbacks.Add("--install-mod", Command.InstallMod);
|
|
||||||
|
|
||||||
if (args.Length == 0) { PrintUsage(); return; }
|
if (args.Length == 0) { PrintUsage(); return; }
|
||||||
var arg = SplitArgs(args[0]);
|
var arg = SplitArgs(args[0]);
|
||||||
@@ -82,10 +82,10 @@ namespace OpenRA.Utility
|
|||||||
Console.WriteLine(" -l,--list-mods List currently installed mods");
|
Console.WriteLine(" -l,--list-mods List currently installed mods");
|
||||||
Console.WriteLine(" -i=MODS,--mod-info=MODS List metadata for MODS (comma separated list of mods)");
|
Console.WriteLine(" -i=MODS,--mod-info=MODS List metadata for MODS (comma separated list of mods)");
|
||||||
Console.WriteLine(" --download-url=URL,DEST Download a file from URL to DEST");
|
Console.WriteLine(" --download-url=URL,DEST Download a file from URL to DEST");
|
||||||
Console.WriteLine(" --install-ra-packages=PATH Install required packages for RA from PATH to CD");
|
Console.WriteLine(" --extract-zip=ZIPFILE,MOD,PATH Extract the zip ZIPFILE to DEST relative to MOD");
|
||||||
Console.WriteLine(" --install-cnc-packages=PATH Install required packages for C&C from PATH to CD");
|
Console.WriteLine(" --install-ra-packages=PATH Install required packages for RA from CD to PATH");
|
||||||
|
Console.WriteLine(" --install-cnc-packages=PATH Install required packages for C&C from CD to PATH");
|
||||||
Console.WriteLine(" --settings-value=SUPPORTDIR,KEY Get value of KEY in SUPPORTDIR/settings.yaml");
|
Console.WriteLine(" --settings-value=SUPPORTDIR,KEY Get value of KEY in SUPPORTDIR/settings.yaml");
|
||||||
Console.WriteLine(" --install-mod=ZIPFILE Install a mod from ZIPFILE");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user