aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-24 20:17:13 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-24 20:17:13 +0000
commitedbebba950d4fc75cd84e2f69648b10f207fb847 (patch)
tree3ed47c8765e916323da426f665a72be2e2703d03
parenta82b71c2bb18273c88778a24b4309847a6b35c04 (diff)
downloadpaludis-edbebba950d4fc75cd84e2f69648b10f207fb847.tar.gz
paludis-edbebba950d4fc75cd84e2f69648b10f207fb847.tar.xz
Include descriptions of available arg options in man pages. Fixes: ticket:45.
-rw-r--r--paludis/args/man.cc74
1 files changed, 73 insertions, 1 deletions
diff --git a/paludis/args/man.cc b/paludis/args/man.cc
index 522cb08..e802b63 100644
--- a/paludis/args/man.cc
+++ b/paludis/args/man.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -19,11 +19,79 @@
#include "man.hh"
#include <ostream>
+#include <sstream>
using namespace paludis;
using namespace paludis::args;
using std::endl;
+namespace
+{
+ struct ExtraText :
+ ArgsVisitorTypes::ConstVisitor
+ {
+ std::stringstream s;
+
+ ExtraText()
+ {
+ }
+
+ void visit(const ArgsOption * const)
+ {
+ }
+
+ void visit(const StringArg * const)
+ {
+ }
+
+ void visit(const AliasArg * const)
+ {
+ }
+
+ void visit(const SwitchArg * const)
+ {
+ }
+
+ void visit(const IntegerArg * const)
+ {
+ }
+
+ void visit(const EnumArg * const e)
+ {
+ for (EnumArg::AllowedArgIterator a(e->begin_allowed_args()), a_end(e->end_allowed_args()) ;
+ a != a_end ; ++a)
+ {
+ s << ".RS" << endl;
+ s << ".TP" << endl;
+ s << ".B \"" << a->first << "\"" << endl;
+ s << a->second << endl;
+ s << ".RE" << endl;
+ }
+ }
+
+ void visit(const StringSetArg * const e)
+ {
+ for (StringSetArg::AllowedArgIterator a(e->begin_allowed_args()), a_end(e->end_allowed_args()) ;
+ a != a_end ; ++a)
+ {
+ s << ".RS" << endl;
+ s << ".TP" << endl;
+ s << ".B \"" << a->first << "\"" << endl;
+ s << ".BR" << endl;
+ s << a->second << endl;
+ s << ".RE" << endl;
+ }
+ }
+ };
+
+ std::ostream &
+ operator<< (std::ostream & s, const ExtraText & t)
+ {
+ s << t.s.str();
+ return s;
+ }
+}
+
void
paludis::args::generate_man(std::ostream & f, const ArgsHandler * const h)
{
@@ -60,6 +128,10 @@ paludis::args::generate_man(std::ostream & f, const ArgsHandler * const h)
f << "\\-" << (*b)->short_name() << " , ";
f << "\\-\\-" << (*b)->long_name() << "\"" << endl;
f << (*b)->description() << endl;
+
+ ExtraText t;
+ (*b)->accept(&t);
+ f << t;
}
}