Joedb 10.4.3
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
SSH_Connection_Builder.h
Go to the documentation of this file.
1#ifndef joedb_SSH_Connection_Builder
2#define joedb_SSH_Connection_Builder
3
6
7namespace joedb
8{
9 /// @ingroup ui
11 {
12 public:
13 const char *get_name() const override {return "ssh";}
14 std::string get_connection_parameters() const override
15 {
16 return "[--port p] [--verbosity v] [--key base64] [--passphrase secret] <user> <host> <path>";
17 }
18
19 void build_connector(Arguments &arguments) override
20 {
21 const auto port = arguments.next_option<unsigned>("port", "p", 22);
22 const auto verbosity = arguments.next_option<int>("verbosity", "v", 0);
23 const auto key = arguments.next_option<beman::cstring_view>("key", "base64", "");
24 const auto passphrase = arguments.next_option<beman::cstring_view>("passphrase", "secret", "");
25
26 const beman::cstring_view user = arguments.get_next("user");
27 const beman::cstring_view host = arguments.get_next("host");
28 const beman::cstring_view path = arguments.get_next("path");
29
30 if (arguments.missing())
31 return;
32
33 connector = std::make_unique<ssh::Connector>
34 (
35 std::string(user),
36 std::string(host),
37 port,
38 verbosity,
39 std::string(key),
40 std::string(passphrase),
41 path.c_str()
42 );
43 }
44 };
45}
46
47#endif
Class for conveniently parsing command-line arguments.
Definition Arguments.h:16
bool missing() const
Definition Arguments.h:157
T next_option(const char *name, const char *description, T default_value)
Definition Arguments.h:120
beman::cstring_view get_next()
const char * get_name() const override
void build_connector(Arguments &arguments) override
std::string get_connection_parameters() const override
std::unique_ptr< Connector > connector