-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
141 lines (119 loc) · 3.65 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <iostream>
#include <vector>
#include <string>
#include <chrono>
#include "./functions.h"
using namespace std;
string getDate(){
chrono::system_clock::time_point now = chrono::system_clock::now();
time_t time = chrono::system_clock::to_time_t(now);
tm timeInfo = *localtime(&time);
string date = to_string(timeInfo.tm_mday) + "/" + to_string(timeInfo.tm_mon + 1) + "/" + to_string(1900 + timeInfo.tm_year);
return date;
}
string removeTrailingSpaces(const string &str) {
size_t start = str.find_first_not_of(' ');
size_t end = str.find_last_not_of(' ');
if (start == std::string::npos) {
// If the string is all spaces
return "";
}
return str.substr(start, end - start + 1);
}
struct TasksWithProject
{
string projectName;
vector<string> tasks;
};
int main()
{
const vector<string> GUIDELINES = {"Start with 'P ' to indicate In progress", "E to terminate", "C to change the project name"};
string heading = "Summary of " + getDate() + ":";
heading = "*" + heading + "*";
const string ending = "*CHECKOUT*";
string punchWord = "*COMPLETED*";
bool terminate = false;
vector<TasksWithProject> tasksWithProject;
cout << endl;
cout << "Guidelines: " << endl;
for(int i = 0; i < GUIDELINES.size(); i++){
const string guideline = GUIDELINES[i];
cout << "- " << guideline << endl;
}
cout << endl;
while (!terminate)
{
TasksWithProject project;
string projectName;
vector<string> tasks;
cout << "Enter the Project Name: ";
getline(cin, projectName);
cout << endl;
if (projectName == "E")
{
break;
}
project.projectName = projectName;
while (true)
{
string task;
cout << "Enter Task: ";
getline(cin, task);
if (task == "E")
{
terminate = true;
break;
}
else if (task == "C")
{
break;
}
project.tasks.push_back(task);
}
tasksWithProject.push_back(project);
}
if (!tasksWithProject.empty())
{
cout << "Generating..." << endl
<< endl;
cout << heading;
cout << endl
<< endl;
string finalText = heading + "\n\n";
for (int i = 0; i < tasksWithProject.size(); i++)
{
const TasksWithProject taskWithProject = tasksWithProject[i];
string project = "";
if(taskWithProject.projectName != ""){
project = '*' + removeTrailingSpaces(taskWithProject.projectName) + ":*";
}
const vector<string> tasks = taskWithProject.tasks;
finalText += project + '\n';
cout << project << endl;
for (int i = 0; i < tasks.size(); i++)
{
string task = tasks[i];
if (task == "")
{
continue;
}
if (task[0] == 'P' & task[1] == ' ')
{
punchWord = "IN PROGRESS";
task = task.substr(2); // removes the portion that indicates that this task is in progress
}
cout << punchWord << " " << task << endl;
finalText += punchWord + " " + task + "\n";
}
if (i < tasksWithProject.size())
{
cout << endl;
}
}
cout << endl;
cout << ending;
finalText += "\n" + ending;
copyToClipboard(finalText);
}
return 0;
}