comparison irccdctl/plugin_info_cli.cpp @ 528:9daccaeedcce

Irccdctl: split cli.hpp, closes #726
author David Demelier <markand@malikania.fr>
date Thu, 16 Nov 2017 23:12:45 +0100
parents
children 27587ff92a64
comparison
equal deleted inserted replaced
527:a88796ed040a 528:9daccaeedcce
1 /*
2 * plugin_info_cli.cpp -- implementation of irccdctl plugin-info
3 *
4 * Copyright (c) 2013-2017 David Demelier <markand@malikania.fr>
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #include <irccd/json_util.hpp>
20
21 #include "plugin_info_cli.hpp"
22
23 namespace irccd {
24
25 namespace ctl {
26
27 std::string plugin_info_cli::name() const
28 {
29 return "plugin-info";
30 }
31
32 void plugin_info_cli::exec(ctl::controller& ctl, const std::vector<std::string>& args)
33 {
34 if (args.size() < 1)
35 throw std::invalid_argument("plugin-info requires 1 argument");
36
37 request(ctl, {{ "plugin", args[0] }}, [] (auto result) {
38 std::cout << std::boolalpha;
39 std::cout << "Author : " << json_util::get_string(result, "author") << std::endl;
40 std::cout << "License : " << json_util::get_string(result, "license") << std::endl;
41 std::cout << "Summary : " << json_util::get_string(result, "summary") << std::endl;
42 std::cout << "Version : " << json_util::get_string(result, "version") << std::endl;
43 });
44 }
45
46 } // !ctl
47
48 } // !irccd