aboutsummaryrefslogtreecommitdiff
path: root/client/main.cpp
blob: 36fc7bb0afe67accb5bc407611cdc996d575fb0c (plain)
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
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <exception>

#include "rl.h"
#include "sock.h"

int main(int argc, char** argv) {
	if (argc < 2) {
		printf("usage: %s addr [port]\n", argv[0]);
		return EXIT_FAILURE;
	}

	// parse arguments
	char* addr = argv[1];
	uint16_t port = 9191;
	if (argc >= 3) port = atoi(argv[2]);

	try {
		// connect to TCP socket (automatically spawns thread)
		PBSocket sock(addr, port);
	} catch (const std::exception& e) {
		printf("error: %s\n", e.what());
		return EXIT_FAILURE;
	}

	// enter main CLI (using GNU readline for comfyness)
	return cli_main();
}