mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
Make use of ArgumentParser and UsageInformation Generator in unlink tool
This commit is contained in:
parent
c76352077a
commit
36cc8d3065
@ -1,25 +1,90 @@
|
|||||||
|
#include <cstdlib>
|
||||||
#include "Utils/Arguments/ArgumentParser.h"
|
#include "Utils/Arguments/ArgumentParser.h"
|
||||||
|
#include "Utils/Arguments/UsageInformation.h"
|
||||||
|
#include "ZoneLoading.h"
|
||||||
|
|
||||||
CommandLineOption* optionMinimalZoneFile = CommandLineOption::Builder::Create()
|
const CommandLineOption* optionHelp = CommandLineOption::Builder::Create()
|
||||||
|
.WithShortName("?")
|
||||||
|
.WithLongName("help")
|
||||||
|
.WithDescription("Displays usage information.")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
const CommandLineOption* optionMinimalZoneFile = CommandLineOption::Builder::Create()
|
||||||
.WithShortName("min")
|
.WithShortName("min")
|
||||||
.WithLongName("minimal-zone")
|
.WithLongName("minimal-zone")
|
||||||
.WithDescription("Minimizes the size of the zone file output by only including assets that are not a dependency of another asset.")
|
.WithDescription("Minimizes the size of the zone file output by only including assets that are not a dependency of another asset.")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
CommandLineOption* optionOutputFolder = CommandLineOption::Builder::Create()
|
const CommandLineOption* optionList = CommandLineOption::Builder::Create()
|
||||||
|
.WithShortName("l")
|
||||||
|
.WithLongName("list")
|
||||||
|
.WithDescription("Lists the contents of a zone instead of writing them to the disk.")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
const CommandLineOption* optionOutputFolder = CommandLineOption::Builder::Create()
|
||||||
.WithShortName("o")
|
.WithShortName("o")
|
||||||
.WithLongName("output-folder")
|
.WithLongName("output-folder")
|
||||||
.WithDescription("Specifies the output folder containing the contents of the unlinked zones. Defaults to ./%zoneName%")
|
.WithDescription("Specifies the output folder containing the contents of the unlinked zones. Defaults to ./%zoneName%")
|
||||||
.WithParameter("outputFolderPath")
|
.WithParameter("outputFolderPath")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
CommandLineOption* commandLineOptions[]
|
const CommandLineOption* commandLineOptions[]
|
||||||
{
|
{
|
||||||
|
optionHelp,
|
||||||
optionMinimalZoneFile,
|
optionMinimalZoneFile,
|
||||||
|
optionList,
|
||||||
optionOutputFolder
|
optionOutputFolder
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, const char** argv)
|
void PrintUsage()
|
||||||
{
|
{
|
||||||
|
UsageInformation usage("unlinker.exe");
|
||||||
|
|
||||||
|
for (auto commandLineOption : commandLineOptions)
|
||||||
|
{
|
||||||
|
usage.AddCommandLineOption(commandLineOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
usage.AddArgument("pathToZone");
|
||||||
|
usage.SetVariableArguments(true);
|
||||||
|
|
||||||
|
usage.Print();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(const int argc, const char** argv)
|
||||||
|
{
|
||||||
|
ArgumentParser argumentParser(commandLineOptions, _countof(commandLineOptions));
|
||||||
|
|
||||||
|
if(!argumentParser.ParseArguments(argc, argv))
|
||||||
|
{
|
||||||
|
PrintUsage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(argumentParser.IsOptionSpecified(optionHelp))
|
||||||
|
{
|
||||||
|
PrintUsage();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<std::string> arguments = argumentParser.GetArguments();
|
||||||
|
const size_t argCount = arguments.size();
|
||||||
|
if(argCount <= 1)
|
||||||
|
{
|
||||||
|
PrintUsage();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(unsigned argIndex = 1; argIndex < argCount; argIndex++)
|
||||||
|
{
|
||||||
|
const std::string& zonePath = arguments[argIndex];
|
||||||
|
|
||||||
|
if(!ZoneLoading::LoadZone(zonePath))
|
||||||
|
{
|
||||||
|
printf("Failed to load zone '%s'.\n", zonePath.c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
#include "ZoneLoading.h"
|
#include "ZoneLoading.h"
|
||||||
|
|
||||||
bool ZoneLoading::LoadZone(std::string& path)
|
bool ZoneLoading::LoadZone(const std::string& path)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
@ -4,5 +4,5 @@
|
|||||||
class ZoneLoading
|
class ZoneLoading
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static bool LoadZone(std::string& path);
|
static bool LoadZone(const std::string& path);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user