paludis Version 3.0.2
The one true package mangler
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
8#include <paludis/paludis.hh>
9
10/** \file
11 *
12 * Basic command line handling for most examples.
13 */
14
15namespace 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 :
35 public paludis::Singleton<CommandLine>
36 {
37 friend class paludis::Singleton<CommandLine>;
38
39 private:
40 CommandLine();
41 ~CommandLine() override;
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 std::string app_name() const override;
52 std::string app_synopsis() const override;
53 std::string app_description() const override;
54
55 ///\}
56
57 ///\name Action arguments
58 ///\{
59
60 paludis::args::ArgsGroup action_args;
63
64 ///\}
65
66 ///\name General arguments
67 ///{
68
69 paludis::args::ArgsGroup general_args;
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 */
85}
86
87#endif
std::string app_description() const override
Definition example_command_line.cc:48
std::string app_synopsis() const override
Definition example_command_line.cc:42
std::string app_name() const override
Definition example_command_line.cc:36
Definition singleton.hh:45
Definition args_group.hh:51
Definition args_handler.hh:60
Definition log_level_arg.hh:49
Definition args_option.hh:238
Definition args_option.hh:209
void show_help_and_exit(const char *const argv[]) PALUDIS_ATTRIBUTE((noreturn))
Definition example_command_line.cc:56
void show_version_and_exit() PALUDIS_ATTRIBUTE((noreturn))
Definition example_command_line.cc:66
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53