aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-30 23:50:50 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-30 23:50:50 +0000
commit017efbc927862033a66301d9c57d9213166874b5 (patch)
tree784d85e26449463fcbe482312d76ffc0c1cb5b9a
parente77c92b13aeb4f362aaf999fa65ee2c2bd431181 (diff)
downloadpaludis-017efbc927862033a66301d9c57d9213166874b5.tar.gz
paludis-017efbc927862033a66301d9c57d9213166874b5.tar.xz
Move most of the man writing code into args. Extend what can be included in a man page. Extend man pages.
-rw-r--r--paludis/args/Makefile.am6
-rw-r--r--paludis/args/args_handler.cc19
-rw-r--r--paludis/args/args_handler.hh17
-rw-r--r--paludis/args/man.hh37
-rw-r--r--src/paludis/command_line.cc34
-rw-r--r--src/paludis/man_paludis.cc39
-rw-r--r--src/qualudis/man_qualudis.cc38
7 files changed, 113 insertions, 77 deletions
diff --git a/paludis/args/Makefile.am b/paludis/args/Makefile.am
index 27d8bae..41d135f 100644
--- a/paludis/args/Makefile.am
+++ b/paludis/args/Makefile.am
@@ -17,7 +17,8 @@ paludis_args_include_HEADERS = \
args_visitor.hh \
bad_value.hh \
missing_value.hh \
- args_dumper.hh
+ args_dumper.hh \
+ man.hh
libpaludisargs_la_SOURCES = $(paludis_args_include_HEADERS) \
args.cc \
@@ -29,7 +30,8 @@ libpaludisargs_la_SOURCES = $(paludis_args_include_HEADERS) \
args_visitor.cc \
bad_value.cc \
missing_value.cc \
- args_dumper.cc
+ args_dumper.cc \
+ man.cc
libpaludisargs_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
diff --git a/paludis/args/args_handler.cc b/paludis/args/args_handler.cc
index 064bad8..22c1ae2 100644
--- a/paludis/args/args_handler.cc
+++ b/paludis/args/args_handler.cc
@@ -47,6 +47,7 @@ namespace paludis
std::list<ArgsGroup *> groups;
std::list<std::string> parameters;
std::list<std::string> usage_lines;
+ std::list<std::pair<std::string, std::string> > environment_lines;
std::map<std::string, ArgsOption *> longopts;
std::map<char, ArgsOption *> shortopts;
@@ -69,6 +70,12 @@ ArgsHandler::add_usage_line(const std::string & l)
}
void
+ArgsHandler::add_enviromnent_variable(const std::string & e, const std::string & desc)
+{
+ _imp->environment_lines.push_back(std::make_pair(e, desc));
+}
+
+void
ArgsHandler::add(ArgsGroup * const g)
{
/// \bug Should check for name uniqueness.
@@ -198,6 +205,18 @@ ArgsHandler::end_usage_lines() const
return UsageLineIterator(_imp->usage_lines.end());
}
+ArgsHandler::EnvironmentLineIterator
+ArgsHandler::begin_environment_lines() const
+{
+ return EnvironmentLineIterator(_imp->environment_lines.begin());
+}
+
+ArgsHandler::EnvironmentLineIterator
+ArgsHandler::end_environment_lines() const
+{
+ return EnvironmentLineIterator(_imp->environment_lines.end());
+}
+
ArgsHandler::ArgsGroupsIterator
ArgsHandler::begin_args_groups() const
{
diff --git a/paludis/args/args_handler.hh b/paludis/args/args_handler.hh
index d162b73..bddc7fd 100644
--- a/paludis/args/args_handler.hh
+++ b/paludis/args/args_handler.hh
@@ -58,6 +58,11 @@ namespace paludis
void add_usage_line(const std::string & l);
/**
+ * Add a new environment line.
+ */
+ void add_enviromnent_variable(const std::string & e, const std::string & desc);
+
+ /**
* Add an new ArgsGroup (called by the ArgsGroup constructor).
*/
void add(ArgsGroup * const);
@@ -140,6 +145,18 @@ namespace paludis
///\}
+ ///\name Iterate over our environment lines (for documentation)
+ ///\{
+
+ typedef libwrapiter::ForwardIterator<ArgsHandler,
+ const std::pair<std::string, std::string> > EnvironmentLineIterator;
+
+ EnvironmentLineIterator begin_environment_lines() const;
+
+ EnvironmentLineIterator end_environment_lines() const;
+
+ ///\}
+
///\name Iterate over our groups
///\{
diff --git a/paludis/args/man.hh b/paludis/args/man.hh
new file mode 100644
index 0000000..1ba8bed
--- /dev/null
+++ b/paludis/args/man.hh
@@ -0,0 +1,37 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
+ *
+ * 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
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_ARGS_MAN_HH
+#define PALUDIS_GUARD_PALUDIS_ARGS_MAN_HH 1
+
+#include <paludis/args/args.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+ namespace args
+ {
+ /**
+ * Write a man page to an ostream.
+ */
+ void generate_man(std::ostream &, const ArgsHandler * const h);
+ }
+}
+
+#endif
diff --git a/src/paludis/command_line.cc b/src/paludis/command_line.cc
index 328f620..03dccd7 100644
--- a/src/paludis/command_line.cc
+++ b/src/paludis/command_line.cc
@@ -107,8 +107,38 @@ CommandLine::CommandLine() :
{
a_dl_max_stack_depth.set_argument(100);
- add_usage_line("[ -q | --query ] [ query options ] [ targets ]");
- add_usage_line("[ -i | --install ] [ install options ] [ targets ]");
+ add_usage_line("--query [query options] target ...");
+ add_usage_line("--install [install options] target ...");
+ add_usage_line("--sync [target (leave blank for all)]");
+ add_usage_line("--contents target ...");
+ add_usage_line("--owner [owner options] files ...");
+ add_usage_line("--version");
+ add_usage_line("--info");
+ add_usage_line("--help");
+
+ add_usage_line("--has-version atom");
+ add_usage_line("--best-version atom");
+ add_usage_line("--environment-variable atom variable");
+ add_usage_line("--configuration-variable repository variable");
+ add_usage_line("--list-repositories [--repository repo1 --repository repo2 ...]");
+ add_usage_line("--list-categories [--repository repo1 ... --category cat1 --category cat2 ...]");
+ add_usage_line("--list-packages [--repository repo1 ... --category cat1 ... --package pkg1 --package pkg2 ...]");
+ add_usage_line("--list-sync-protocols");
+ add_usage_line("--list-repository-formats");
+ add_usage_line("--list-dep-tag-categories");
+ add_usage_line("--list-vulnerabilities [--repository repo1 ...]");
+ add_usage_line("--update-news");
+
+ add_enviromnent_variable("PALUDIS_HOME", "Overrides the home directory used when searching "
+ "for configuration files etc.");
+ add_enviromnent_variable("PALUDIS_NO_GLOBAL_HOOKS", "Don't use global hooks. Mostly for "
+ "internal and test case use.");
+ add_enviromnent_variable("PALUDIS_SKIP_CONFIG", "Don't load configuration. Mostly for "
+ "internal and test case use.");
+ add_enviromnent_variable("PALUDIS_EBUILD_DIR", "Where to look for ebuild.bash and related "
+ "utilities.");
+ add_enviromnent_variable("PALUDIS_REPOSITORY_SO_DIR", "Where to look for repository .so "
+ "files.");
}
std::string
diff --git a/src/paludis/man_paludis.cc b/src/paludis/man_paludis.cc
index 5eaf612..500b7f9 100644
--- a/src/paludis/man_paludis.cc
+++ b/src/paludis/man_paludis.cc
@@ -18,7 +18,7 @@
*/
#include "command_line.hh"
-#include "config.h"
+#include <paludis/args/man.hh>
#include <iostream>
#include <cstdlib>
@@ -29,42 +29,7 @@ using std::endl;
int
main(int, char *[])
{
- cout << ".TH \"" << CommandLine::get_instance()->app_name() << "\" "
- << CommandLine::get_instance()->man_section() << endl;
-
- cout << ".SH NAME" << endl;
- cout << CommandLine::get_instance()->app_name() << " \\- "
- << CommandLine::get_instance()->app_synopsis() << endl;
-
- cout << ".SH SYNOPSIS" << endl;
-
- for (CommandLine::UsageLineIterator u(CommandLine::get_instance()->begin_usage_lines()),
- u_end(CommandLine::get_instance()->end_usage_lines()) ; u != u_end ; ++u)
- cout << ".B " << CommandLine::get_instance()->app_name() << " " << *u << endl << endl;
-
- cout << ".SH DESCRIPTION" << endl;
- cout << CommandLine::get_instance()->app_description() << endl;
-
- cout << ".SH OPTIONS" << endl;
-
- for (CommandLine::ArgsGroupsIterator a(CommandLine::get_instance()->begin_args_groups()),
- a_end(CommandLine::get_instance()->end_args_groups()) ; a != a_end ; ++a)
- {
- cout << ".SS \"" << (*a)->name() << "\"" << endl;
- cout << (*a)->description() << endl;
-
- for (paludis::args::ArgsGroup::Iterator b((*a)->begin()), b_end((*a)->end()) ;
- b != b_end ; ++b)
- {
- cout << ".TP" << endl;
- cout << ".B \"";
- if ((*b)->short_name())
- cout << "\\-" << (*b)->short_name() << " , ";
- cout << "\\-\\-" << (*b)->long_name() << "\"" << endl;
- cout << (*b)->description() << endl;
- }
- }
-
+ paludis::args::generate_man(cout, CommandLine::get_instance());
return EXIT_SUCCESS;
}
diff --git a/src/qualudis/man_qualudis.cc b/src/qualudis/man_qualudis.cc
index 3570880..a47cae4 100644
--- a/src/qualudis/man_qualudis.cc
+++ b/src/qualudis/man_qualudis.cc
@@ -18,6 +18,7 @@
*/
#include "qualudis_command_line.hh"
+#include <paludis/args/man.hh>
#include "config.h"
#include <iostream>
@@ -29,42 +30,7 @@ using std::endl;
int
main(int, char *[])
{
- cout << ".TH \"" << QualudisCommandLine::get_instance()->app_name() << "\" "
- << QualudisCommandLine::get_instance()->man_section() << endl;
-
- cout << ".SH NAME" << endl;
- cout << QualudisCommandLine::get_instance()->app_name() << " \\- "
- << QualudisCommandLine::get_instance()->app_synopsis() << endl;
-
- cout << ".SH SYNOPSIS" << endl;
-
- for (QualudisCommandLine::UsageLineIterator u(QualudisCommandLine::get_instance()->begin_usage_lines()),
- u_end(QualudisCommandLine::get_instance()->end_usage_lines()) ; u != u_end ; ++u)
- cout << ".B " << QualudisCommandLine::get_instance()->app_name() << " " << *u << endl << endl;
-
- cout << ".SH DESCRIPTION" << endl;
- cout << QualudisCommandLine::get_instance()->app_description() << endl;
-
- cout << ".SH OPTIONS" << endl;
-
- for (QualudisCommandLine::ArgsGroupsIterator a(QualudisCommandLine::get_instance()->begin_args_groups()),
- a_end(QualudisCommandLine::get_instance()->end_args_groups()) ; a != a_end ; ++a)
- {
- cout << ".SS \"" << (*a)->name() << "\"" << endl;
- cout << (*a)->description() << endl;
-
- for (paludis::args::ArgsGroup::Iterator b((*a)->begin()), b_end((*a)->end()) ;
- b != b_end ; ++b)
- {
- cout << ".TP" << endl;
- cout << ".B \"";
- if ((*b)->short_name())
- cout << "\\-" << (*b)->short_name() << " , ";
- cout << "\\-\\-" << (*b)->long_name() << "\"" << endl;
- cout << (*b)->description() << endl;
- }
- }
-
+ paludis::args::generate_man(cout, QualudisCommandLine::get_instance());
return EXIT_SUCCESS;
}