Mercurial > irccd
comparison irccdctl/rule_move_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 | 7cd7b2cdf923 |
comparison
equal
deleted
inserted
replaced
527:a88796ed040a | 528:9daccaeedcce |
---|---|
1 /* | |
2 * rule_move_cli.cpp -- implementation of irccdctl rule-move | |
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 "rule_move_cli.hpp" | |
20 | |
21 namespace irccd { | |
22 | |
23 namespace ctl { | |
24 | |
25 std::string rule_move_cli::name() const | |
26 { | |
27 return "rule-move"; | |
28 } | |
29 | |
30 void rule_move_cli::exec(ctl::controller& ctl, const std::vector<std::string>& args) | |
31 { | |
32 if (args.size() < 2) | |
33 throw std::invalid_argument("rule-move requires 2 arguments"); | |
34 | |
35 int from = 0; | |
36 int to = 0; | |
37 | |
38 try { | |
39 from = std::stoi(args[0]); | |
40 to = std::stoi(args[1]); | |
41 } catch (...) { | |
42 throw std::invalid_argument("invalid number"); | |
43 } | |
44 | |
45 request(ctl, { | |
46 { "command", "rule-move" }, | |
47 { "from", from }, | |
48 { "to", to } | |
49 }); | |
50 } | |
51 | |
52 } // !ctl | |
53 | |
54 } // !irccd |