patrick
/
plasp
Archived
1
0
Fork 0
This repository has been archived on 2023-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
plasp/app/src/plasp-app/Commands.cpp

37 lines
1.1 KiB
C++

#include <plasp-app/Commands.h>
#include <map>
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Commands
//
////////////////////////////////////////////////////////////////////////////////////////////////////
static const std::map<std::string, Command> commandNames =
{
{"help", Command::Help},
{"-h", Command::Help},
{"--help", Command::Help},
{"version", Command::Version},
{"-v", Command::Version},
{"--version", Command::Version},
{"check-syntax", Command::CheckSyntax},
{"requirements", Command::Requirements},
{"pretty-print", Command::PrettyPrint},
{"normalize", Command::Normalize},
{"translate", Command::Translate},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
Command parseCommand(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;
}