summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project2/common/options.cpp6
-rw-r--r--project2/common/options.h3
-rw-r--r--project2/console/consoleEnvironment.cpp10
3 files changed, 18 insertions, 1 deletions
diff --git a/project2/common/options.cpp b/project2/common/options.cpp
index b2777fa..37b3f06 100644
--- a/project2/common/options.cpp
+++ b/project2/common/options.cpp
@@ -115,6 +115,12 @@ Options::consume(const Glib::ustring & n, const Glib::ustring & p, const Variabl
}
}
+const Options::OptionList &
+Options::allOptions() const
+{
+ return options;
+}
+
const Options::Option *
Options::find(const Glib::ustring & n) const {
BOOST_FOREACH(const OptionPtr & o, options) {
diff --git a/project2/common/options.h b/project2/common/options.h
index b336854..8a2584c 100644
--- a/project2/common/options.h
+++ b/project2/common/options.h
@@ -48,6 +48,7 @@ class Options {
virtual void consume(const Glib::ustring & name, const Glib::ustring & platform, const VariableType & value) const = 0;
};
typedef boost::intrusive_ptr<Option> OptionPtr;
+ typedef std::list<OptionPtr> OptionList;
Options(const Glib::ustring & name);
@@ -89,9 +90,9 @@ class Options {
const Option * find(const Glib::ustring & name) const;
const Glib::ustring name;
+ const OptionList & allOptions() const;
private:
- typedef std::list<OptionPtr> OptionList;
OptionList options;
};
diff --git a/project2/console/consoleEnvironment.cpp b/project2/console/consoleEnvironment.cpp
index 28da574..6bbeeed 100644
--- a/project2/console/consoleEnvironment.cpp
+++ b/project2/console/consoleEnvironment.cpp
@@ -25,8 +25,18 @@ class ShowHelpTrigger : public Options::Target {
}
void consume(const Glib::ustring &, const VariableType &) const {
fprintf(stdout, "Help\n");
+ LoaderBase::onAllComponents(boost::bind(&ShowHelpTrigger::outputOptions, this, _1));
exit(1);
}
+ private:
+ void outputOptions(ComponentLoader * cl) const {
+ const Options * options = cl->options();
+ if (!options) return;
+ fprintf(stdout, " * %s\n", options->name.c_str());
+ BOOST_FOREACH(const auto & option, options->allOptions()) {
+ fprintf(stdout, " * %s - %s\n", option->name().c_str(), option->description().c_str());
+ }
+ }
};
ConsoleEnvironment::ConsoleEnvironment(int c, char ** v) :