aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ingmar Vanhassel <ingmar@exherbo.org> 2009-02-16 17:05:28 +0100
committerAvatar Ingmar Vanhassel <ingmar@exherbo.org> 2009-03-23 23:22:54 +0100
commit741547fa6af344884f8b0a0ed19301ff4ee112d3 (patch)
tree58d1cb886c984ad4db0938038821f28d87a9384c
parent9f2c388c6954d13c7562d4e625fc786bc60f1c74 (diff)
downloadpaludis-741547fa6af344884f8b0a0ed19301ff4ee112d3.tar.gz
paludis-741547fa6af344884f8b0a0ed19301ff4ee112d3.tar.xz
Add cave print-repository-formats
-rw-r--r--src/clients/cave/Makefile.am3
-rw-r--r--src/clients/cave/cmd_print_repository_formats.cc97
-rw-r--r--src/clients/cave/cmd_print_repository_formats.hh44
-rw-r--r--src/clients/cave/command_factory.cc2
4 files changed, 145 insertions, 1 deletions
diff --git a/src/clients/cave/Makefile.am b/src/clients/cave/Makefile.am
index a60e744..4982d0f 100644
--- a/src/clients/cave/Makefile.am
+++ b/src/clients/cave/Makefile.am
@@ -26,6 +26,7 @@ command_MANS = \
cave-print-owners.1 \
cave-print-packages.1 \
cave-print-repositories.1 \
+ cave-print-repository-formats.1 \
cave-print-sets.1 \
cave-print-sync-protocols.1 \
cave-show.1 \
@@ -80,6 +81,7 @@ libcave_a_SOURCES = \
cmd_print_owners.cc cmd_print_owners.hh \
cmd_print_packages.cc cmd_print_packages.hh \
cmd_print_repositories.cc cmd_print_repositories.hh \
+ cmd_print_repository_formats.cc cmd_print_repository_formats.hh \
cmd_print_sets.cc cmd_print_sets.hh \
cmd_print_sync_protocols.cc cmd_print_sync_protocols.hh \
cmd_show.cc cmd_show.hh \
@@ -101,7 +103,6 @@ libcave_a_SOURCES = \
# cmd_print_executables.cc \
# cmd_print_id_actions.cc \
# cmd_print_id_masks.cc \
-# cmd_print_repository_formats.cc \
# cmd_print_repository_metadata.cc \
# cmd_print_set.cc \
# cmd_print_sync_protocol_metadata.cc \
diff --git a/src/clients/cave/cmd_print_repository_formats.cc b/src/clients/cave/cmd_print_repository_formats.cc
new file mode 100644
index 0000000..617eb7b
--- /dev/null
+++ b/src/clients/cave/cmd_print_repository_formats.cc
@@ -0,0 +1,97 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Ingmar Vanhassel
+ *
+ * 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_repository_formats.hh"
+
+#include <paludis/args/args.hh>
+#include <paludis/args/do_help.hh>
+#include <paludis/repository_factory.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+
+#include <set>
+#include <iostream>
+#include <cstdlib>
+
+#include "command_command_line.hh"
+
+using namespace paludis;
+using namespace cave;
+using std::cout;
+using std::endl;
+
+namespace
+{
+ struct PrintRepositoryFormatsCommandLine :
+ CaveCommandCommandLine
+ {
+ virtual std::string app_name() const
+ {
+ return "cave print-repository-formats";
+ }
+
+ virtual std::string app_synopsis() const
+ {
+ return "Prints a list of available repository formats.";
+ }
+
+ virtual std::string app_description() const
+ {
+ return "Prints a list of available repository formats. No formatting is used, making the output suitable for "
+ "parsing by scripts.";
+ }
+ };
+}
+
+int
+PrintRepositoryFormatsCommand::run(
+ const std::tr1::shared_ptr<Environment> &,
+ const std::tr1::shared_ptr<const Sequence<std::string > > & args
+ )
+{
+ PrintRepositoryFormatsCommandLine cmdline;
+ cmdline.run(args, "CAVE", "CAVE_PRINT_REPOSITORY_FORMATS_OPTIONS", "CAVE_PRINT_REPOSITORY_FORMATS_CMDLINE");
+
+ if (cmdline.a_help.specified())
+ {
+ cout << cmdline;
+ return EXIT_SUCCESS;
+ }
+
+ if (cmdline.begin_parameters() != cmdline.end_parameters())
+ throw args::DoHelp("print-repository-formats takes no parameters");
+
+ std::set<std::string> repository_formats(RepositoryFactory::get_instance()->begin_keys(), RepositoryFactory::get_instance()->end_keys());
+
+ if (! repository_formats.empty())
+ {
+ std::copy(repository_formats.begin(), repository_formats.end(), std::ostream_iterator<std::string>(cout, "\n"));
+ return EXIT_SUCCESS;
+ }
+
+ return EXIT_FAILURE;
+}
+
+std::tr1::shared_ptr<args::ArgsHandler>
+PrintRepositoryFormatsCommand::make_doc_cmdline()
+{
+ return make_shared_ptr(new PrintRepositoryFormatsCommandLine);
+}
diff --git a/src/clients/cave/cmd_print_repository_formats.hh b/src/clients/cave/cmd_print_repository_formats.hh
new file mode 100644
index 0000000..bfa1d38
--- /dev/null
+++ b/src/clients/cave/cmd_print_repository_formats.hh
@@ -0,0 +1,44 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Ingmar Vanhassel
+ *
+ * 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_SRC_CLIENTS_CAVE_CMD_PRINT_REPOSITORY_FORMATS_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_PRINT_REPOSITORY_FORMATS_HH 1
+
+#include "command.hh"
+
+namespace paludis
+{
+ namespace cave
+ {
+ class PALUDIS_VISIBLE PrintRepositoryFormatsCommand :
+ public Command
+ {
+ public:
+ int run(
+ const std::tr1::shared_ptr<Environment> &,
+ const std::tr1::shared_ptr<const Sequence<std::string > > & args
+ );
+
+ std::tr1::shared_ptr<args::ArgsHandler> make_doc_cmdline();
+ };
+ }
+}
+
+
+#endif
diff --git a/src/clients/cave/command_factory.cc b/src/clients/cave/command_factory.cc
index 72fc4cb..5184f73 100644
--- a/src/clients/cave/command_factory.cc
+++ b/src/clients/cave/command_factory.cc
@@ -36,6 +36,7 @@
#include "cmd_print_owners.hh"
#include "cmd_print_packages.hh"
#include "cmd_print_repositories.hh"
+#include "cmd_print_repository_formats.hh"
#include "cmd_print_sets.hh"
#include "cmd_print_sync_protocols.hh"
#include "cmd_show.hh"
@@ -77,6 +78,7 @@ CommandFactory::CommandFactory() :
_imp->handlers.insert(std::make_pair("print-owners", make_command<PrintOwnersCommand>));
_imp->handlers.insert(std::make_pair("print-packages", make_command<PrintPackagesCommand>));
_imp->handlers.insert(std::make_pair("print-repositories", make_command<PrintRepositoriesCommand>));
+ _imp->handlers.insert(std::make_pair("print-repository-formats", make_command<PrintRepositoryFormatsCommand>));
_imp->handlers.insert(std::make_pair("print-sets", make_command<PrintSetsCommand>));
_imp->handlers.insert(std::make_pair("print-sync-protocols", make_command<PrintSyncProtocolsCommand>));
_imp->handlers.insert(std::make_pair("show", make_command<ShowCommand>));