-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappl.cpp
108 lines (89 loc) · 2.29 KB
/
appl.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "./pch.hpp"
#include "./component.hpp"
#include "./workspace.hpp"
#include "./appl.hpp"
namespace dvo{
//
std::string const appl::dvoVersion = "0.1.0";
//
appl::appl() :
base<appl>()
, home()
, rootComponent()
, currentWorkspace()
, workspaces(){
}
appl::~appl(){
}
bool appl::init(int argc, char* argv[]){
this->workspaces.push_back(this->currentWorkspace = workspace::create(this->rootComponent = component::create(boost::filesystem::path("/"), component_ptr())));
this->rootComponent->scan(this->home);
return true;
}
/*
[-r|--recursive]
[*] filter
> help - display help
> update - update repos in .dvo at current level [-r]
> push - push all changes from .dvo repos
> reload - reset all loaded components and load again
> ls [-r][*] - list available component at the current level
> exit
> <goal>[;<goal>[;...]] [<comp>[;<comp>[;...]]] - execute set of goals on set of components
> ws ls - list of all availabe workspaces
> ws checkout <ws_name> [--create|-c]
- switch or create_and_switch to the new workspace
> ws remove <ws_name> - delete workspace
*/
void appl::run(){
std::istream& is = std::cin;
std::ostream& os = std::cout;
//
os << "--- DevOps helper [" << appl::dvoVersion << "] ---" << std::endl;
//
std::string str;
while (true) {
os << "[" << this->home.string() << "]:" << this->currentWorkspace->getPrompt() << "> ";
std::getline(is, str);
os << str << std::endl;
if (str == "exit"){
break;
} else if (str == "ls"){
this->currentWorkspace->getCursor()->ls(os, " ");
}
}
}
void appl::cleanup(){
this->currentWorkspace.reset();
//
BOOST_FOREACH(workspace_ptr w, this->workspaces){ w->cleanup(); }
this->workspaces.clear();
//
this->rootComponent->cleanup();
this->rootComponent.reset();
}
}
#if 0
std::string str;
os << "> ";
while (true) {
char c;
//c = _getch();
c = getchar();
os << c;
printf("%d", c);
//is.getline(&c, 1);
if (c == '\r' || c == '\n'){
os << std::endl << str << std::endl;
if (str == "exit"){
break;
}
str = "";
os << "> ";
}
else{
str += c;
}
//
}
#endif