aboutsummaryrefslogtreecommitdiff
path: root/src/clients/cave/command_command_line.cc
blob: f2718c1eba8d0361c28a78e65b5d6f2b58dd22ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* vim: set sw=4 sts=4 et foldmethod=syntax : */

/*
 * Copyright (c) 2008 Saleem Abdulrasool
 *
 * This file is part of the Paludis package manager. Paludis is free software;
 * you can redistribute it and/or modify it under the terms of the GNU General
 * Public License version 2, as published by the Free Software Foundation.
 *
 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "command_command_line.hh"
#include <iostream>

using namespace paludis;
using namespace cave;

CaveCommandCommandLine::CaveCommandCommandLine() :
    g_global_options(main_options_section(), "Global Options", "Global options, used by every subcommand."),
    a_help(&g_global_options, "help", 'h', "display help message", false)
{
}

std::ostream &
paludis::cave::operator<< (std::ostream & os, const CaveCommandCommandLine & cmdline)
{
    if (cmdline.begin_usage_lines() != cmdline.end_usage_lines())
    {
        os << "usage: ";
        for (args::ArgsHandler::UsageLineConstIterator u_begin(cmdline.begin_usage_lines()), u(u_begin), u_end(cmdline.end_usage_lines()) ;
                u != u_end ; ++u)
        {
            if (u != u_begin)
                os << "       ";
            os << cmdline.app_name() << " " << *u << std::endl;
        }
        os << std::endl;
    }

    os << static_cast<const args::ArgsHandler &>(cmdline);

    return os;
}