Mercurial > irccd
changeset 334:84728196ca19
Irccdctl: bring back server-mode
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 09 Nov 2016 20:31:17 +0100 |
parents | c99877913565 |
children | 3f805ae62174 |
files | irccdctl/cli-server-mode.cpp irccdctl/cli-server-mode.hpp |
diffstat | 2 files changed, 101 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/irccdctl/cli-server-mode.cpp Wed Nov 09 20:31:17 2016 +0100 @@ -0,0 +1,48 @@ +/* + * cli-server-mode.cpp -- implementation of irccdctl server-mode + * + * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "cli-server-mode.hpp" + +namespace irccd { + +namespace cli { + +ServerModeCli::ServerModeCli() + : Cli("server-mode", + "the the user mode", + "server-mode server mode", + "Set the irccd's user mode.\n\n" + "Example:\n" + "\tirccdctl server-mode +i") +{ +} + +void ServerModeCli::exec(Irccdctl &irccdctl, const std::vector<std::string> &args) +{ + if (args.size() < 2) + throw std::invalid_argument("server-mode requires 2 arguments"); + + check(request(irccdctl, { + { "server", args[0] }, + { "mode", args[1] } + })); +} + +} // !command + +} // !irccd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/irccdctl/cli-server-mode.hpp Wed Nov 09 20:31:17 2016 +0100 @@ -0,0 +1,53 @@ +/* + * cli-server-mode.hpp -- implementation of irccdctl server-mode + * + * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef IRCCDCTL_CLI_SERVER_MODE_HPP +#define IRCCDCTL_CLI_SERVER_MODE_HPP + +/** + * \file cli-server-mode.hpp + * \brief Implementation of irccdctl server-mode. + */ + +#include "cli.hpp" + +namespace irccd { + +namespace cli { + +/** + * \brief Implementation of irccdctl server-mode. + */ +class ServerModeCli : public Cli { +public: + /** + * Default constructor. + */ + ServerModeCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector<std::string> &args) override; +}; + +} // !cli + +} // !irccd + +#endif // !IRCCDCTL_CLI_SERVER_MODE_HPP