-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
33 lines (26 loc) · 727 Bytes
/
Copy pathmain.cpp
File metadata and controls
33 lines (26 loc) · 727 Bytes
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
#include <iostream>
#include <chrono>
#include <thread>
using namespace std;
const string USAGE = "Usage:\n\t<source> | slow [delay-milliseconds]";
int main(int argc, char *argv[]) {
int delay_milliseconds = 250;
if (argc > 2) {
cout << USAGE << endl;
return 1;
}
if (argc == 2) {
string argument = (string) argv[1];
if (argument == "--help" || argument == "-h") {
cout << USAGE << endl;
return 0;
}
delay_milliseconds = stoi(argv[1]);
}
string pipeInput;
while(getline(cin, pipeInput)) {
cout << pipeInput << endl;
this_thread::sleep_for(chrono::milliseconds(delay_milliseconds));
}
return 0;
}