simplified config
This commit is contained in:
parent
b3ba5998ff
commit
d587646b32
3 changed files with 5 additions and 18 deletions
|
|
@ -1,14 +1,9 @@
|
|||
#include "../src/config.hpp"
|
||||
#include <iostream>
|
||||
#include "config.hpp"
|
||||
#include <unistd.h>
|
||||
#include <stdexcept>
|
||||
|
||||
Configuration::Configuration(int argc, char **argv)
|
||||
{
|
||||
if (argc <= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "i:o:l")) != -1)
|
||||
{
|
||||
|
|
@ -24,8 +19,7 @@ Configuration::Configuration(int argc, char **argv)
|
|||
debug_lexer = true;
|
||||
break;
|
||||
default:
|
||||
std::cerr << "Please specify input arguments\n";
|
||||
throw std::runtime_error("Invalid arguments");
|
||||
}
|
||||
}
|
||||
valid = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
#pragma once
|
||||
#include <getopt.h>
|
||||
#include <string>
|
||||
|
||||
class Configuration
|
||||
{
|
||||
public:
|
||||
std::string input_file = "";
|
||||
std::string output_file = "";
|
||||
std::string input_file;
|
||||
std::string output_file;
|
||||
bool debug_lexer = false;
|
||||
|
||||
bool valid = false;
|
||||
Configuration(int argc, char **argv);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,11 +30,6 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
ParserCtx ctx;
|
||||
Configuration config(argc, argv);
|
||||
if (!config.valid)
|
||||
{
|
||||
std::cout << "Please provide a valid configuration\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (config.debug_lexer)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue