Skip to content

Commit

Permalink
Add command line argument support
Browse files Browse the repository at this point in the history
Example usage:
.\WoWResourceParser.exe -e -p --adtFolder=E:\_NewProjectWoW\_HOCKA\mpqs\world\maps\DungeonMode --dataFolder=E:\_NewProjectWoW\_HOCKA\mpqs "--destFolder=D:\WoW 3.3.5a\Data\patch-5.MPQ"
  • Loading branch information
stoneharry committed Jun 21, 2021
1 parent 29fff6f commit 2eb2919
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
63 changes: 60 additions & 3 deletions WoWResourceParser/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using CommandLine;

namespace WoWResourceParser
{
Expand All @@ -20,19 +21,75 @@ static void Log(string message)
}
}

public class Options
{
[Option('e', "extract", Required = false, HelpText = "Set whether to extract the assets used to assets.txt.")]
public bool Extract { get; set; }

[Option('p', "package", Required = false, HelpText = "Set whether to package the assets.txt to the destination folder.")]
public bool Package { get; set; }

[Option("assetsFilePath", Required = false, HelpText = "Override the assets.txt file path")]
public string AssetsFilePath { get; set; }

[Option("adtFolder", Required = true, HelpText = "Sets the ADT (map) folder to read from")]
public string AdtPath { get; set; }

[Option("dataFolder", Required = true, HelpText = "Sets the data folder to read assets from")]
public string DataPath { get; set; }

[Option("destFolder", Required = true, HelpText = "Sets the destination folder for packaging to")]
public string DestPath { get; set; }
}

static void Main(string[] args)
{
bool extract = true;
bool package = true;
bool extract = false;
bool package = false;

string adtFolder = "E:\\_NewProjectWoW\\_HOCKA\\HourofTwillight\\world\\maps\\DungeonMode";
string adtFolder = "E:\\_NewProjectWoW\\_HOCKA\\mpqs\\world\\maps\\DungeonMode";
string dataFolder = "E:\\_NewProjectWoW\\_HOCKA\\mpqs";
string assetsFilePath = "assets.txt";

string destFolder = "D:\\WoW 3.3.5a\\Data\\patch-5.MPQ";

File.Delete(LogPath);

Parser.Default.ParseArguments<Options>(args)
.WithParsed(o =>
{
if (o.Extract)
{
extract = true;
Log("--Extract = true");
}
if (o.Package)
{
package = true;
Log("--Package = true");
}
if (o.AssetsFilePath?.Length > 0)
{
assetsFilePath = o.AssetsFilePath;
Log("--AssetsPath = " + assetsFilePath);
}
if (o.AdtPath?.Length > 0)
{
adtFolder = o.AdtPath;
Log("--AdtPath = " + adtFolder);
}
if (o.DataPath?.Length > 0)
{
dataFolder = o.DataPath;
Log("--DataPath = " + dataFolder);
}
if (o.DestPath?.Length > 0)
{
destFolder = o.DestPath;
Log("--DestPath = " + destFolder);
}
});

if (extract)
{
ExtractAssets(adtFolder, dataFolder, assetsFilePath);
Expand Down
4 changes: 4 additions & 0 deletions WoWResourceParser/WoWResourceParser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLine, Version=2.8.0.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.2.8.0\lib\net461\CommandLine.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -48,6 +51,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
4 changes: 4 additions & 0 deletions WoWResourceParser/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineParser" version="2.8.0" targetFramework="net461" />
</packages>

0 comments on commit 2eb2919

Please sign in to comment.