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