Allow argument chaining.
Example to extract test.gma into test and afterwards overwriting test.gma using files in test2: gmadsharp extract test.gma test create test2 test.gmalua-bytecode
parent
ca52705a04
commit
d7661343bb
|
@ -2,6 +2,7 @@
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GarrysMod.AddonCreator.Addon;
|
||||
|
||||
namespace GarrysMod.AddonCreator
|
||||
|
@ -9,6 +10,8 @@ namespace GarrysMod.AddonCreator
|
|||
internal static class Program
|
||||
{
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
while (args.Any())
|
||||
{
|
||||
switch (args.Length == 0 ? "" : args[0])
|
||||
{
|
||||
|
@ -34,8 +37,8 @@ namespace GarrysMod.AddonCreator
|
|||
foreach (var file in folder.EnumerateFiles("*", SearchOption.AllDirectories))
|
||||
{
|
||||
var relpath =
|
||||
MakeRelativePath(folder.FullName, file.FullName).Replace(Path.DirectorySeparatorChar, '/');
|
||||
Console.WriteLine("Adding: {0}", relpath);
|
||||
MakeRelativePath(folder.FullName, file.FullName)
|
||||
.Replace(Path.DirectorySeparatorChar, '/');
|
||||
|
||||
addon.Files.Add(relpath, new PhysicalAddonFileInfo(file.FullName));
|
||||
}
|
||||
|
@ -45,8 +48,10 @@ namespace GarrysMod.AddonCreator
|
|||
addon.Export(output);
|
||||
|
||||
Console.WriteLine("Done.");
|
||||
args = args.Skip(3).ToArray();
|
||||
break;
|
||||
}
|
||||
|
||||
case "extract":
|
||||
{
|
||||
if (args.Length < 3)
|
||||
|
@ -90,7 +95,8 @@ namespace GarrysMod.AddonCreator
|
|||
{
|
||||
var relpath = file.Key;
|
||||
var targetFile =
|
||||
new FileInfo(Path.Combine(folder.FullName, relpath.Replace('/', Path.DirectorySeparatorChar)));
|
||||
new FileInfo(Path.Combine(folder.FullName,
|
||||
relpath.Replace('/', Path.DirectorySeparatorChar)));
|
||||
|
||||
Console.WriteLine("Extracting: {0}", relpath);
|
||||
|
||||
|
@ -116,12 +122,16 @@ namespace GarrysMod.AddonCreator
|
|||
}
|
||||
fs.Write(toWriteBuf.ToArray(), 0, toWrite);
|
||||
}
|
||||
|
||||
fs.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("Done.");
|
||||
args = args.Skip(3).ToArray();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
Console.WriteLine("Usage: {0} <command> <arguments>", Process.GetCurrentProcess().ProcessName);
|
||||
Console.WriteLine();
|
||||
|
@ -131,7 +141,8 @@ namespace GarrysMod.AddonCreator
|
|||
Console.WriteLine("\t{0}\t{1}", "create", "Creates a GMA file.");
|
||||
Console.WriteLine("\t\tArguments: Input folder path, output GMA file path");
|
||||
Console.WriteLine();
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue