comparison irccdctl/command-plugin-reload.cpp @ 0:1158cffe5a5e

Initial import
author David Demelier <markand@malikania.fr>
date Mon, 08 Feb 2016 16:43:14 +0100
parents
children afff3f16d86e
comparison
equal deleted inserted replaced
-1:000000000000 0:1158cffe5a5e
1 /*
2 * command-plugin-reload.cpp -- implementation of irccdctl plugin-reload
3 *
4 * Copyright (c) 2013-2016 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 "command-plugin-reload.h"
20
21 namespace irccd {
22
23 namespace command {
24
25 void PluginReload::usage(Irccdctl &) const
26 {
27 log::warning() << "usage: " << sys::programName() << " plugin-reload name\n\n";
28 log::warning() << "Reload a plugin, parameter name is the plugin to reload.\n";
29 log::warning() << "The plugin must be loaded.\n\n";
30 log::warning() << "Example:\n";
31 log::warning() << "\t" << sys::programName() << " plugin-reload logger" << std::endl;
32 }
33
34 void PluginReload::exec(Irccdctl &ctl, const std::vector<std::string> &args) const
35 {
36 if (args.size() < 1)
37 throw std::invalid_argument("plugin-reload requires 1 argument");
38
39 ctl.connection().send(json::object({
40 { "command", "plugin-reload" },
41 { "plugin", args[0] }
42 }).toJson(0));
43
44 ctl.connection().verify("plugin-reload");
45 }
46
47 } // !command
48
49 } // !irccd