-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_main.cpp
More file actions
56 lines (48 loc) · 1.47 KB
/
client_main.cpp
File metadata and controls
56 lines (48 loc) · 1.47 KB
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
#include "Merchant.h"
#include "Agent.h"
#include "args/args.hxx"
#include "common.h"
#include <iostream>
int main(const int argc, const char* argv[])
{
args::ArgumentParser argparser("Elf Stream Client", "");
args::HelpFlag help(argparser, "help", "Display this help menu", {"help"});
args::Group required(argparser, "", args::Group::Validators::All);
args::Positional<std::string> elf_path_arg (required, "Elf file", "Path for elf file located on server");
args::ValueFlag<std::string> host_arg (required, "host", "Hostname or ip address", {'H', "host"});
args::ValueFlag<int> port_arg (argparser, "port", "Port", {'p', "port"});
args::PositionalList<std::string> vargs_arg (argparser, "args", "Arguments to pass to inferior");
// Don't show that "-- can be used to terminate.." thing
argparser.helpParams.showTerminator = false;
try
{
argparser.ParseCLI(argc, argv);
}
catch(const args::Help&)
{
std::cout<<argparser;
return EXIT_SUCCESS;
}
// Some args related error
catch (const args::ParseError& e)
{
std::cerr << e.what() << std::endl;
std::cerr << argparser;
return EXIT_FAILURE;
}
// Some args validation related error
catch (const args::ValidationError& e)
{
std::cerr << argparser;
return EXIT_FAILURE;
}
int port = port_arg?args::get(port_arg):ELFSTREAM_PORT;
auto merchant = std::make_shared<Merchant>(
args::get(host_arg),
args::get(elf_path_arg),
port
);
Agent agent(merchant);
agent.spawn(args::get(vargs_arg));
agent.run();
}