aboutsummaryrefslogtreecommitdiff
path: root/doc/api/cplusplus/examples/example_command_line.hh
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-10-15 11:10:38 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-10-15 11:10:38 +0000
commit503481c165de28bc0a5db25b7848708df7cb2668 (patch)
tree41eac48b7d7915ca0e7e88bb5dc9ea65225d3b99 /doc/api/cplusplus/examples/example_command_line.hh
parent8f51d97de6b38b8bc8a9b129baecf4bebd183c7b (diff)
downloadpaludis-503481c165de28bc0a5db25b7848708df7cb2668.tar.gz
paludis-503481c165de28bc0a5db25b7848708df7cb2668.tar.xz
Start reworking docs
Diffstat (limited to 'doc/api/cplusplus/examples/example_command_line.hh')
-rw-r--r--doc/api/cplusplus/examples/example_command_line.hh88
1 files changed, 88 insertions, 0 deletions
diff --git a/doc/api/cplusplus/examples/example_command_line.hh b/doc/api/cplusplus/examples/example_command_line.hh
new file mode 100644
index 000000000..62a4d73d1
--- /dev/null
+++ b/doc/api/cplusplus/examples/example_command_line.hh
@@ -0,0 +1,88 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#ifndef PALUDIS_GUARD_DOC_EXAMPLES_EXAMPLE_COMMAND_LINE_HH
+#define PALUDIS_GUARD_DOC_EXAMPLES_EXAMPLE_COMMAND_LINE_HH 1
+
+#include <paludis/args/args.hh>
+#include <paludis/args/log_level_arg.hh>
+#include <paludis/paludis.hh>
+
+/** \file
+ *
+ * Basic command line handling for most examples.
+ */
+
+namespace examples
+{
+ /**
+ * This class provides basic command line handling for most examples.
+ *
+ * Most Paludis clients should support at least '--help', '--version'
+ * and '--log-level'. If paludis::EnvironmentMaker is used to create
+ * the environment (as opposed to, say, paludis::NoConfigEnvironment),
+ * then '--environment' must also be an option.
+ *
+ * Clients are free to use whichever command line handling library they
+ * prefer, but for convenience all Paludis core clients use a common utility
+ * library with a much simpler interface than that provided by overly C-ish
+ * getopt derivatives.
+ *
+ * The command line is a singleton -- that is, only one instance of
+ * it exists globally. This avoids the need to pass around lots of
+ * parameters.
+ */
+ class CommandLine :
+ public paludis::args::ArgsHandler,
+ public paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonTag>
+ {
+ friend class paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonTag>;
+
+ private:
+ CommandLine();
+ ~CommandLine();
+
+ public:
+ virtual void run(const int, const char * const * const,
+ const std::string & client, const std::string & env_var,
+ const std::string & env_prefix);
+
+ ///\name Program information
+ ///\{
+
+ virtual std::string app_name() const;
+ virtual std::string app_synopsis() const;
+ virtual std::string app_description() const;
+
+ ///\}
+
+ ///\name Action arguments
+ ///\{
+
+ paludis::args::ArgsGroup action_args;
+ paludis::args::SwitchArg a_version;
+ paludis::args::SwitchArg a_help;
+
+ ///\}
+
+ ///\name General arguments
+ ///{
+
+ paludis::args::ArgsGroup general_args;
+ paludis::args::LogLevelArg a_log_level;
+ paludis::args::StringArg a_environment;
+
+ ///}
+ };
+
+ /**
+ * Show a '--help' message, and exit.
+ */
+ void show_help_and_exit(const char * const argv[]) PALUDIS_ATTRIBUTE((noreturn));
+
+ /**
+ * Show a '--version' message, and exit.
+ */
+ void show_version_and_exit() PALUDIS_ATTRIBUTE((noreturn));
+}
+
+#endif