コード例 #1
0
ファイル: exa_dgreset.cpp プロジェクト: OznOg/OpenExanodes
void exa_dgreset::dump_examples(std::ostream &out, bool show_hidden) const
{
    out << "Reset the disk group " << Boldify("mygroup") << " in the cluster "
        << Boldify("mycluster") << ":" << std::endl;

    out << "  " << "exa_dgreset mycluster:mygroup" << std::endl;
    out << std::endl;
}
コード例 #2
0
ファイル: info_help.cpp プロジェクト: alban/OpenExanodes
void Command::dump_section(std::ostream &out,
                           const std::string &section,
                           bool show_hidden) const
{
    out << std::endl << Boldify(section) << std::endl;
    out << std::endl;
}
コード例 #3
0
ファイル: info_help.cpp プロジェクト: alban/OpenExanodes
void Command::Subtitle(std::ostream &out, const std::string &s) const
{
    out << " ";  /* Ugly hack introduced because the endl were ignored... I don't know why */
    out << std::endl;
    out << Boldify(s) << std::endl;
}
コード例 #4
0
ファイル: info_help.cpp プロジェクト: alban/OpenExanodes
void Command::dump_usage(std::ostream &out, bool show_hidden) const
{
    std::stringstream ss;

    out << std::endl;
    ss << get_name() << " - ";
    dump_short_description(ss, show_hidden);
    indented_dump(ss.str(), out);
    out << std::endl << std::endl;

    ss.str("");
    dump_section(out, "Synopsis", show_hidden);
    dump_synopsis(ss, show_hidden);
    indented_dump(ss.str(), out);
    out << std::endl;

    ss.str("");
    dump_section(out, "Description", show_hidden);
    dump_full_description(ss, show_hidden);
    indented_dump(ss.str(), out);
    out << std::endl;

    ss.str("");
    dump_output_section(ss, show_hidden);
    indented_dump(ss.str(), out);
    out << std::endl;

    dump_section(out, "Options", show_hidden);

    std::vector<std::string> str_opts;
    size_t max_width(0);

    for (CommandOptions::const_iterator it = _options.begin();
         it != _options.end(); ++it)
    {
        if (show_hidden == false && it->second->is_hidden())
            continue;
        std::stringstream ss;

        std::string short_opt("-");
        short_opt.append(1, it->second->get_short_opt());
        std::string long_opt("--");
        long_opt.append(it->second->get_long_opt());

        ss << "  ";
        ss << Boldify(short_opt)  << ", " << Boldify(long_opt);

        if (it->second->is_arg_expected())
            ss << " " << it->second->get_arg_name();

        str_opts.push_back(ss.str());
        size_t real_size = Get_real_string_size(ss.str());
        if (real_size > max_width)
            max_width = real_size;
    }

    size_t i(0);
    for (CommandOptions::const_iterator it = _options.begin();
         it != _options.end(); ++it)
    {
        if (show_hidden == false && it->second->is_hidden())
            continue;

        indented_dump(str_opts.at(i), out, 0, max_width + 2, true, true);

        std::stringstream ss;

        ss << it->second->get_description();
        if (it->second->is_arg_expected() &&
            it->second->is_mandatory() == false &&
            it->second->get_default_value().empty() == false)
            ss << std::endl << "Default is '" <<
            it->second->get_default_value() << "'.";

        indented_dump(ss.str(), out, max_width + 2,
                      Get_tty_cols(), false, false);
        out << std::endl;

        ++i;
    }
    out << std::endl;

    dump_section(out, "Examples", show_hidden);
    ss.str("");
    dump_examples(ss, show_hidden);
    indented_dump(ss.str(), out);
    out << std::endl;

    if (_see_also.empty() == false)
    {
        dump_section(out, "See also", show_hidden);
        ss.str("");
        dump_see_also(ss, show_hidden);
        indented_dump(ss.str(), out);
        out << std::endl;
        out << std::endl;
    }

    dump_section(out, "Author", show_hidden);
    ss.str("");
    ss << EXA_COPYRIGHT << std::endl;
    indented_dump(ss.str(), out);
    out << std::endl;
}