-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
42 lines (38 loc) · 1.14 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
#include <iostream>
#include <cstdlib>
int main(int argc, char* argv[]) {
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " <file_path> **<server_url>" << std::endl;
return 1;
}
// if (argv[1]=='-h' || argv[1]=='--help') {
// std::cout << "Usage: " << argv[0] << " <file_path> **<server_url>" << std::endl;
// return 0;
// }
// if (argv[1]=='-v' || argv[1]=='--version') {
// std::cout << "Version: 1.0" << std::endl;
// return 0;
// }
std::string command = "curl -sF 'file=@";
command += argv[1];
command += "'";
if (argc > 3){
command += " ";
command += argv[3];
} else{
command += " ";
command += "https://upload.doshare.me/upload";
}
command += " -o result.json";
std::cout << "Executing: " << command << std::endl;
int result = system(command.c_str());
if (result == -1) {
std::cerr << "Error executing curl command." << std::endl;
return 1;
} else if (result > 0) {
std::cerr << "curl command failed with code: " << result << std::endl;
return 1;
}
std::cout << "File upload successful!" << std::endl;
return 0;
}