-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
77 lines (65 loc) · 1.83 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include <sys/stat.h>
#include "pip.h"
using namespace pip2cmake;
int main(int argc, char* argv[])
{
std::vector<std::string> args(argv + 1, argv + argc);
if (args.size() != 0)
{
bool verbose = false;
std::string inputpath = "";
std::string outputpath = "";
int i = 0;
while (i < args.size() && (args[i].rfind("-", 0) == 0))
{
std::string arg = args[i++];
if (arg == "-v")
{
verbose = true;
}
else if (arg == "-i")
{
if (i < args.size())
{
inputpath = args[i++];
}
else
{
std::cerr << "-i requires a file path" << std::endl;
}
}
else if (arg == "-o")
{
if (i < args.size())
{
outputpath = args[i++];
break;
}
else
{
std::cerr << "-o requires a path" << std::endl;
}
}
}
if(!inputpath.empty())
{
struct stat info;
if( stat( inputpath.c_str(), &info ) == 0 )
{
std::cout << "Opening \"" << inputpath << "\"" << std::endl;
pip proj(inputpath.c_str(), outputpath);
proj.gen_cmake();
if(verbose)
{
std::cout << proj << std::endl;
}
std::cout << "Created \"" << proj.get_cmake_file() << "\"" << std::endl;
}
else
{
std::cerr << "In-Valid file: " << inputpath << std::endl;
}
}
}
}