view irccdctl/cli-plugin-info.cpp @ 335:3f805ae62174

Irccdctl: bring back server-nick
author David Demelier <markand@malikania.fr>
date Wed, 09 Nov 2016 20:46:56 +0100
parents 2ea95292fa77
children
line wrap: on
line source

/*
 * 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