From 03b43aad42c8eca03937148cda7afffceeeeca1c Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 21 Sep 2016 23:49:20 -0700 Subject: Place command_cache in a separate cpp file --- toolsrc/src/commands_cache.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 toolsrc/src/commands_cache.cpp (limited to 'toolsrc/src/commands_cache.cpp') diff --git a/toolsrc/src/commands_cache.cpp b/toolsrc/src/commands_cache.cpp new file mode 100644 index 000000000..3a08c4a64 --- /dev/null +++ b/toolsrc/src/commands_cache.cpp @@ -0,0 +1,39 @@ +#include "vcpkg_Commands.h" +#include "vcpkg_System.h" +#include "vcpkg_Files.h" +#include "vcpkg.h" + +namespace vcpkg +{ + void cache_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) + { + args.check_max_args(0); + + auto begin_it = fs::directory_iterator(paths.packages); + auto end_it = fs::directory_iterator(); + + if (begin_it == end_it) + { + System::println("No packages are cached."); + exit(EXIT_SUCCESS); + } + + for (; begin_it != end_it; ++begin_it) + { + const auto& path = begin_it->path(); + + auto file_contents = Files::get_contents(path / "CONTROL"); + if (auto text = file_contents.get()) + { + auto pghs = parse_paragraphs(*text); + if (pghs.size() != 1) + continue; + + auto src = BinaryParagraph(pghs[0]); + System::println(src.displayname().c_str()); + } + } + + exit(EXIT_SUCCESS); + } +} -- cgit v1.2.3 From fc1e55173b23afeb46142e6d656043a4b6f4b21c Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 30 Sep 2016 11:24:04 -0700 Subject: Rename check_max_args to check_max_arg_count and introduce min/exact variants --- toolsrc/src/commands_cache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toolsrc/src/commands_cache.cpp') diff --git a/toolsrc/src/commands_cache.cpp b/toolsrc/src/commands_cache.cpp index 3a08c4a64..0d70f0f29 100644 --- a/toolsrc/src/commands_cache.cpp +++ b/toolsrc/src/commands_cache.cpp @@ -7,7 +7,7 @@ namespace vcpkg { void cache_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) { - args.check_max_args(0); + args.check_exact_arg_count(0); auto begin_it = fs::directory_iterator(paths.packages); auto end_it = fs::directory_iterator(); -- cgit v1.2.3