mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +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/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")
|
||||
.WithLongName("minimal-zone")
|
||||
.WithDescription("Minimizes the size of the zone file output by only including assets that are not a dependency of another asset.")
|
||||
.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")
|
||||
.WithLongName("output-folder")
|
||||
.WithDescription("Specifies the output folder containing the contents of the unlinked zones. Defaults to ./%zoneName%")
|
||||
.WithParameter("outputFolderPath")
|
||||
.Build();
|
||||
|
||||
CommandLineOption* commandLineOptions[]
|
||||
const CommandLineOption* commandLineOptions[]
|
||||
{
|
||||
optionHelp,
|
||||
optionMinimalZoneFile,
|
||||
optionList,
|
||||
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;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#include "ZoneLoading.h"
|
||||
|
||||
bool ZoneLoading::LoadZone(std::string& path)
|
||||
bool ZoneLoading::LoadZone(const std::string& path)
|
||||
{
|
||||
return false;
|
||||
}
|
@ -4,5 +4,5 @@
|
||||
class ZoneLoading
|
||||
{
|
||||
public:
|
||||
static bool LoadZone(std::string& path);
|
||||
static bool LoadZone(const std::string& path);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user