paludis
Version 1.4.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
examples
example_command_line.hh
Go to the documentation of this file.
1
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3
#ifndef PALUDIS_GUARD_DOC_EXAMPLES_EXAMPLE_COMMAND_LINE_HH
4
#define PALUDIS_GUARD_DOC_EXAMPLES_EXAMPLE_COMMAND_LINE_HH 1
5
6
#include <
paludis/args/args.hh
>
7
#include <
paludis/args/log_level_arg.hh
>
8
#include <
paludis/paludis.hh
>
9
10
/** \file
11
*
12
* Basic command line handling for most examples.
13
*/
14
15
namespace
examples
16
{
17
/**
18
* This class provides basic command line handling for most examples.
19
*
20
* Most Paludis clients should support at least '--help', '--version'
21
* and '--log-level'. If paludis::EnvironmentFactory is used to create
22
* the environment then '--environment' must also be an option.
23
*
24
* Clients are free to use whichever command line handling library they
25
* prefer, but for convenience all Paludis core clients use a common utility
26
* library with a much simpler interface than that provided by overly C-ish
27
* getopt derivatives.
28
*
29
* The command line is a singleton -- that is, only one instance of
30
* it exists globally. This avoids the need to pass around lots of
31
* parameters.
32
*/
33
class
CommandLine
:
34
public
paludis::args::ArgsHandler
,
35
public
paludis::Singleton
<CommandLine>
36
{
37
friend
class
paludis::Singleton
<CommandLine>;
38
39
private
:
40
CommandLine();
41
~CommandLine();
42
43
public
:
44
virtual
void
run(
const
int
,
const
char
*
const
*
const
,
45
const
std::string & client,
const
std::string & env_var,
46
const
std::string & env_prefix);
47
48
///\name Program information
49
///\{
50
51
virtual
std::string
app_name
()
const
;
52
virtual
std::string
app_synopsis
()
const
;
53
virtual
std::string
app_description
()
const
;
54
55
///\}
56
57
///\name Action arguments
58
///\{
59
60
paludis::args::ArgsGroup
action_args;
61
paludis::args::SwitchArg
a_version;
62
paludis::args::SwitchArg
a_help;
63
64
///\}
65
66
///\name General arguments
67
///{
68
69
paludis::args::ArgsGroup
general_args;
70
paludis::args::LogLevelArg
a_log_level;
71
paludis::args::StringArg
a_environment;
72
73
///}
74
};
75
76
/**
77
* Show a '--help' message, and exit.
78
*/
79
void
show_help_and_exit(
const
char
*
const
argv[])
PALUDIS_ATTRIBUTE
((noreturn));
80
81
/**
82
* Show a '--version' message, and exit.
83
*/
84
void
show_version_and_exit()
PALUDIS_ATTRIBUTE
((noreturn));
85
}
86
87
#endif
Generated on Thu May 16 2013 14:09:42 for paludis by
1.8.3.1