From 749cd532f72108b26a78cd2f0012e6abd72b3ce8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 28 Sep 2015 08:38:40 +0200 Subject: Factory common code for version, repository location parsing --- bpkg/rep-info.cxx | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'bpkg/rep-info.cxx') diff --git a/bpkg/rep-info.cxx b/bpkg/rep-info.cxx index 64ac9b1..224866c 100644 --- a/bpkg/rep-info.cxx +++ b/bpkg/rep-info.cxx @@ -14,6 +14,7 @@ #include #include #include +#include using namespace std; using namespace butl; @@ -29,24 +30,7 @@ namespace bpkg fail << "repository location argument expected" << info << "run 'bpkg help rep-info' for more information"; - // Figure out the repository location. - // - // @@ The same code as in rep-add, factor out. - // - const char* arg (args.next ()); - repository_location rl; - try - { - rl = repository_location (arg, repository_location ()); - - if (rl.relative ()) // Throws if location is empty. - rl = repository_location ( - dir_path (arg).complete ().normalize ().string ()); - } - catch (const invalid_argument& e) - { - fail << "invalid repository location '" << arg << "': " << e.what (); - } + repository_location rl (parse_location (args.next ())); // Fetch everything we will need before printing anything. // -- cgit v1.1