2017-10-14 01:20:26 +02:00
|
|
|
#ifndef __PLASP_APP__COMMAND_TYPE_H
|
|
|
|
#define __PLASP_APP__COMMAND_TYPE_H
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
2017-10-14 01:37:40 +02:00
|
|
|
#include <plasp-app/commands/CommandBeautify.h>
|
2017-10-14 01:43:56 +02:00
|
|
|
#include <plasp-app/commands/CommandCheckSyntax.h>
|
2017-10-14 01:20:26 +02:00
|
|
|
#include <plasp-app/commands/CommandHelp.h>
|
|
|
|
#include <plasp-app/commands/CommandNormalize.h>
|
|
|
|
#include <plasp-app/commands/CommandTranslate.h>
|
|
|
|
#include <plasp-app/commands/CommandVersion.h>
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Command Type
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
enum class CommandType
|
|
|
|
{
|
|
|
|
Help,
|
|
|
|
Version,
|
|
|
|
CheckSyntax,
|
|
|
|
Requirements,
|
2017-10-14 01:37:40 +02:00
|
|
|
Beautify,
|
2017-10-14 01:20:26 +02:00
|
|
|
Normalize,
|
|
|
|
Translate
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static const std::map<std::string, CommandType> commandNames =
|
|
|
|
{
|
|
|
|
{"help", CommandType::Help},
|
|
|
|
{"-h", CommandType::Help},
|
|
|
|
{"--help", CommandType::Help},
|
|
|
|
{"version", CommandType::Version},
|
|
|
|
{"-v", CommandType::Version},
|
|
|
|
{"--version", CommandType::Version},
|
|
|
|
{"check-syntax", CommandType::CheckSyntax},
|
|
|
|
{"requirements", CommandType::Requirements},
|
2017-10-14 01:37:40 +02:00
|
|
|
{"beautify", CommandType::Beautify},
|
2017-10-14 01:20:26 +02:00
|
|
|
{"normalize", CommandType::Normalize},
|
|
|
|
{"translate", CommandType::Translate},
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
const auto parseCommandType =
|
|
|
|
[](const std::string &commandString)
|
|
|
|
{
|
|
|
|
const auto matchingCommand = commandNames.find(commandString);
|
|
|
|
|
|
|
|
if (matchingCommand == commandNames.cend())
|
|
|
|
throw std::runtime_error(std::string("“") + commandString + "” is not a plasp command");
|
|
|
|
|
|
|
|
return matchingCommand->second;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-10-14 01:43:56 +02:00
|
|
|
using AvailableCommands = std::tuple<CommandTranslate, CommandNormalize, CommandCheckSyntax, CommandBeautify, CommandHelp, CommandVersion>;
|
2017-10-14 01:20:26 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#endif
|