-
Notifications
You must be signed in to change notification settings - Fork 26
/
client.h
53 lines (43 loc) · 1.42 KB
/
client.h
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
/*
* Copyright (c) 2020 SUSE LLC
*
* Licensed under LGPL-2.1 (see LICENSE)
*/
#pragma once
#include <string>
#include <vector>
#include <boost/program_options.hpp>
#include <windows.h>
typedef void (*GetOptionsFunc)(
boost::program_options::positional_options_description &positonal_opts,
boost::program_options::options_description &named_opts);
typedef DWORD (*ExecuteFunc)(const boost::program_options::variables_map &vm);
class Client {
public:
struct Command {
std::string name;
std::vector<std::string> aliases;
std::string description;
ExecuteFunc execute = nullptr;
GetOptionsFunc get_options = nullptr;
Command(std::string _name,
std::vector<std::string> _aliases,
std::string _description,
ExecuteFunc _execute,
GetOptionsFunc _get_options = nullptr)
: name(_name)
, aliases(_aliases)
, description(_description)
, execute(_execute)
, get_options(_get_options)
{
Client::commands.push_back(this);
}
};
static std::vector<Command*> commands;
static const size_t LINE_WIDTH = 80;
static const size_t MIN_LCOLUMN_WIDTH = 20;
DWORD execute(int argc, const char** argv);
static Command* get_command(std::string name);
static void get_common_options(boost::program_options::options_description& options);
};