mirror of
https://github.com/lucaspalomodevelop/autom.git
synced 2026-03-12 23:27:21 +00:00
change makefile and cleanup code
This commit is contained in:
parent
ac141ec143
commit
cc5235838a
16
.vscode/settings.json
vendored
16
.vscode/settings.json
vendored
@ -48,6 +48,20 @@
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"typeinfo": "cpp"
|
||||
"typeinfo": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"ios": "cpp",
|
||||
"xfacet": "cpp",
|
||||
"xiosbase": "cpp",
|
||||
"xlocale": "cpp",
|
||||
"xlocinfo": "cpp",
|
||||
"xlocnum": "cpp",
|
||||
"xmemory": "cpp",
|
||||
"xstddef": "cpp",
|
||||
"xstring": "cpp",
|
||||
"xtr1common": "cpp",
|
||||
"xtree": "cpp",
|
||||
"xutility": "cpp"
|
||||
}
|
||||
}
|
||||
16
makefile
16
makefile
@ -1,5 +1,11 @@
|
||||
all:
|
||||
g++ -c ./src/main.cpp
|
||||
g++ -c ./src/command.cpp
|
||||
g++ -std=c++11 main.o command.o -o ./bin/autom
|
||||
./bin/autom help
|
||||
CC = g++
|
||||
CFLAGS = -std=c++11 -Wall
|
||||
SRCDIR = ./src
|
||||
BINDIR = ./bin
|
||||
|
||||
$(BINDIR)/main: $(SRCDIR)/main.cpp $(SRCDIR)/command.cpp $(SRCDIR)/inputparser.cpp
|
||||
$(CC) $(CFLAGS) $^ -o $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(BINDIR)/autom
|
||||
@ -1,5 +1,5 @@
|
||||
#include "command.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
Command::Command() {}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
class Command
|
||||
{
|
||||
|
||||
38
src/inputparser.cpp
Normal file
38
src/inputparser.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include "./inputparser.h"
|
||||
|
||||
InputParser::InputParser(int argc, char *argv[])
|
||||
{
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
std::string arg(argv[i]);
|
||||
if (arg.find("-") == 0)
|
||||
{
|
||||
std::string key = arg.substr(1);
|
||||
if (i + 1 < argc)
|
||||
{
|
||||
std::string value(argv[i + 1]);
|
||||
if (value.find("-") != 0)
|
||||
{
|
||||
args[key] = value;
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
args[key] = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
args[key] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std::string InputParser::getValue(std::string key)
|
||||
{
|
||||
return args[key];
|
||||
}
|
||||
bool InputParser::hasKey(std::string key)
|
||||
{
|
||||
return args.count(key) > 0;
|
||||
}
|
||||
@ -1,37 +1,20 @@
|
||||
#ifndef INPUTPARSER_H
|
||||
#define INPUTPARSER_H
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
|
||||
|
||||
class InputParser
|
||||
{
|
||||
std::map<std::string, std::string> args;
|
||||
|
||||
public:
|
||||
InputParser(int argc, char *argv[]) {
|
||||
for (int i = 1; i < argc; i++) {
|
||||
std::string arg(argv[i]);
|
||||
if (arg.find("-") == 0) {
|
||||
std::string key = arg.substr(1);
|
||||
if (i + 1 < argc) {
|
||||
std::string value(argv[i + 1]);
|
||||
if (value.find("-") != 0) {
|
||||
args[key] = value;
|
||||
i++;
|
||||
} else {
|
||||
args[key] = "";
|
||||
}
|
||||
} else {
|
||||
args[key] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std::string getValue(std::string key) {
|
||||
return args[key];
|
||||
}
|
||||
bool hasKey(std::string key) {
|
||||
return args.count(key) > 0;
|
||||
}
|
||||
InputParser(int argc, char *argv[]);
|
||||
std::string getValue(std::string key);
|
||||
bool hasKey(std::string key);
|
||||
};
|
||||
|
||||
#endif // INPUTPARSER_H
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
_mkdir(dir.c_str());
|
||||
#else
|
||||
mkdir(dir.c_str(), 0777);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user