Mercurial > irccd
changeset 320:2ea95292fa77
Irccdctl: bring back plugin-info
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 31 Oct 2016 12:54:19 +0100 |
parents | 04e83ea7147b |
children | f23d71fa2b40 |
files | irccdctl/cli-plugin-info.cpp irccdctl/cli-plugin-info.hpp |
diffstat | 2 files changed, 109 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/irccdctl/cli-plugin-info.cpp Mon Oct 31 12:54:19 2016 +0100 @@ -0,0 +1,56 @@ +/* + * cli-plugin-info.cpp -- implementation of irccdctl plugin-info + * + * 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 <iostream> + +#include <util.hpp> + +#include "cli-plugin-info.hpp" + +namespace irccd { + +namespace cli { + +PluginInfoCli::PluginInfoCli() + : Cli("plugin-info", + "get plugin information", + "plugin-info plugin", + "Get plugin information\n\n" + "Example:\n" + "\tirccdctl plugin-info ask" + ) +{ +} + +void PluginInfoCli::exec(Irccdctl &irccdctl, const std::vector<std::string> &args) +{ + if (args.size() < 1) + throw std::invalid_argument("plugin-info requires 1 argument"); + + auto result = request(irccdctl, {{ "plugin", args[0] }}); + + std::cout << std::boolalpha; + std::cout << "Author : " << util::json::getString(result, "author") << std::endl; + std::cout << "License : " << util::json::getString(result, "license") << std::endl; + std::cout << "Summary : " << util::json::getString(result, "summary") << std::endl; + std::cout << "Version : " << util::json::getString(result, "version") << std::endl; +} + +} // !cli + +} // !irccd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/irccdctl/cli-plugin-info.hpp Mon Oct 31 12:54:19 2016 +0100 @@ -0,0 +1,53 @@ +/* + * cli-plugin-info.hpp -- implementation of irccdctl plugin-info + * + * 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_PLUGIN_INFO_HPP +#define IRCCDCTL_CLI_PLUGIN_INFO_HPP + +/** + * \file cli-plugin-info.hpp + * \brief Implementation of irccdctl plugin-info. + */ + +#include "cli.hpp" + +namespace irccd { + +namespace cli { + +/** + * \brief Implementation of irccdctl plugin-info. + */ +class PluginInfoCli : public Cli { +public: + /** + * Default constructor. + */ + PluginInfoCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector<std::string> &args) override; +}; + +} // !commands + +} // !irccd + +#endif // !IRCCDCTL_CLI_PLUGIN_INFO_HPP