aboutsummaryrefslogtreecommitdiff
path: root/src/clients/cave/cmd_print_commands.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-10-25 11:49:36 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-10-25 11:49:36 +0100
commitbd9aa0272d7e2821074d64479cca90312939621c (patch)
tree0ed5739b60aa57b6f3d72e9983ae2bca36b3048b /src/clients/cave/cmd_print_commands.cc
parentab50405a661d1e8af907aace115823ccd6be8a10 (diff)
downloadpaludis-bd9aa0272d7e2821074d64479cca90312939621c.tar.gz
paludis-bd9aa0272d7e2821074d64479cca90312939621c.tar.xz
Start work on cave
Diffstat (limited to 'src/clients/cave/cmd_print_commands.cc')
-rw-r--r--src/clients/cave/cmd_print_commands.cc86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/clients/cave/cmd_print_commands.cc b/src/clients/cave/cmd_print_commands.cc
new file mode 100644
index 000000000..35262e4b8
--- /dev/null
+++ b/src/clients/cave/cmd_print_commands.cc
@@ -0,0 +1,86 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * 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
+ */
+
+#include "cmd_print_commands.hh"
+#include "command_factory.hh"
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/args/args.hh>
+#include <paludis/args/do_help.hh>
+#include <cstdlib>
+#include <iostream>
+#include <algorithm>
+#include <set>
+
+using namespace paludis;
+using namespace cave;
+using std::cout;
+using std::endl;
+
+namespace
+{
+ struct PrintCommandsCommandLine :
+ args::ArgsHandler
+ {
+ virtual std::string app_name() const
+ {
+ return "cave print-commands";
+ }
+
+ virtual std::string app_synopsis() const
+ {
+ return "Prints a list of known cave commands.";
+ }
+
+ virtual std::string app_description() const
+ {
+ return "Prints a list of known cave commands. No formatting is used, making the output suitable for "
+ "parsing by scripts.";
+ }
+
+ PrintCommandsCommandLine()
+ {
+ add_usage_line("");
+ }
+ };
+}
+
+int
+PrintCommandsCommand::run(
+ const std::tr1::shared_ptr<Environment> &,
+ const std::tr1::shared_ptr<const Sequence<std::string > > & args
+ )
+{
+ PrintCommandsCommandLine cmdline;
+ cmdline.run(args, "CAVE", "CAVE_PRINT_COMMANDS_OPTIONS", "CAVE_PRINT_COMMANDS_CMDLINE");
+
+ if (cmdline.begin_parameters() != cmdline.end_parameters())
+ throw args::DoHelp("print-commands takes no parameters");
+
+ std::copy(CommandFactory::get_instance()->begin(), CommandFactory::get_instance()->end(),
+ std::ostream_iterator<std::string>(cout, "\n"));
+
+ return EXIT_SUCCESS;
+}
+
+std::tr1::shared_ptr<args::ArgsHandler>
+PrintCommandsCommand::make_doc_cmdline()
+{
+ return make_shared_ptr(new PrintCommandsCommandLine);
+}
+